From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../testsuite/25_algorithms/adjacent_find/1.cc | 66 +++ .../25_algorithms/adjacent_find/check_type.cc | 41 ++ .../requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ libstdc++-v3/testsuite/25_algorithms/all_of/1.cc | 70 +++ .../testsuite/25_algorithms/all_of/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/any_of/1.cc | 70 +++ .../testsuite/25_algorithms/any_of/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/binary_search/1.cc | 53 ++ .../testsuite/25_algorithms/binary_search/2.cc | 63 +++ .../25_algorithms/binary_search/check_type.cc | 41 ++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ libstdc++-v3/testsuite/25_algorithms/copy/1.cc | 63 +++ libstdc++-v3/testsuite/25_algorithms/copy/2.cc | 64 +++ libstdc++-v3/testsuite/25_algorithms/copy/3.cc | 65 +++ libstdc++-v3/testsuite/25_algorithms/copy/34595.cc | 54 ++ libstdc++-v3/testsuite/25_algorithms/copy/4.cc | 65 +++ .../25_algorithms/copy/deque_iterators/1.cc | 51 ++ .../25_algorithms/copy/move_iterators/1.cc | 64 +++ .../copy/requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ .../copy/streambuf_iterators/char/1.cc | 75 +++ .../copy/streambuf_iterators/char/2.cc | 77 +++ .../copy/streambuf_iterators/char/3.cc | 71 +++ .../copy/streambuf_iterators/char/4.cc | 58 ++ .../copy/streambuf_iterators/wchar_t/1.cc | 75 +++ .../copy/streambuf_iterators/wchar_t/2.cc | 76 +++ .../copy/streambuf_iterators/wchar_t/3.cc | 71 +++ .../copy/streambuf_iterators/wchar_t/4.cc | 55 ++ .../copy_backward/deque_iterators/1.cc | 52 ++ .../copy_backward/move_iterators/1.cc | 66 +++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/copy_if/check_type.cc | 59 +++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ libstdc++-v3/testsuite/25_algorithms/copy_n/1.cc | 53 ++ libstdc++-v3/testsuite/25_algorithms/copy_n/2.cc | 54 ++ libstdc++-v3/testsuite/25_algorithms/copy_n/3.cc | 55 ++ libstdc++-v3/testsuite/25_algorithms/copy_n/4.cc | 55 ++ .../25_algorithms/copy_n/move_iterators/1.cc | 65 +++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/count/1.cc | 57 ++ .../testsuite/25_algorithms/count/check_type.cc | 41 ++ .../count/requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/count_if/1.cc | 64 +++ .../testsuite/25_algorithms/count_if/check_type.cc | 51 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/equal/1.cc | 72 +++ .../testsuite/25_algorithms/equal/check_type.cc | 47 ++ .../25_algorithms/equal/no_operator_ne.cc | 39 ++ .../equal/requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/equal_range/1.cc | 62 +++ .../testsuite/25_algorithms/equal_range/2.cc | 89 ++++ .../25_algorithms/equal_range/check_type.cc | 42 ++ .../requirements/explicit_instantiation/2.cc | 42 ++ .../requirements/explicit_instantiation/pod.cc | 41 ++ libstdc++-v3/testsuite/25_algorithms/fill/1.cc | 63 +++ libstdc++-v3/testsuite/25_algorithms/fill/2.cc | 63 +++ libstdc++-v3/testsuite/25_algorithms/fill/3.cc | 41 ++ libstdc++-v3/testsuite/25_algorithms/fill/35725.cc | 29 + libstdc++-v3/testsuite/25_algorithms/fill/4.cc | 75 +++ .../fill/requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc | 75 +++ .../testsuite/25_algorithms/fill_n/25306.cc | 30 ++ .../testsuite/25_algorithms/fill_n/35725.cc | 29 + .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/find/1.cc | 57 ++ libstdc++-v3/testsuite/25_algorithms/find/17441.cc | 42 ++ libstdc++-v3/testsuite/25_algorithms/find/39546.cc | 43 ++ .../testsuite/25_algorithms/find/check_type.cc | 37 ++ .../find/istreambuf_iterators/char/1.cc | 83 +++ .../find/istreambuf_iterators/char/2.cc | 61 +++ .../find/istreambuf_iterators/wchar_t/1.cc | 83 +++ .../find/istreambuf_iterators/wchar_t/2.cc | 59 +++ .../find/requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ libstdc++-v3/testsuite/25_algorithms/find_end/1.cc | 56 ++ .../testsuite/25_algorithms/find_end/check_type.cc | 52 ++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ .../testsuite/25_algorithms/find_first_of/1.cc | 57 ++ .../25_algorithms/find_first_of/check_type.cc | 48 ++ .../25_algorithms/find_first_of/concept_check_1.cc | 46 ++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ libstdc++-v3/testsuite/25_algorithms/find_if/1.cc | 71 +++ .../testsuite/25_algorithms/find_if/check_type.cc | 48 ++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../testsuite/25_algorithms/find_if_not/1.cc | 73 +++ .../25_algorithms/find_if_not/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/for_each/1.cc | 67 +++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/generate_n/25306.cc | 30 ++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ .../headers/algorithm/algorithm_parallel_mode.cc | 22 + .../headers/algorithm/parallel_algorithm.cc | 22 + .../headers/algorithm/parallel_algorithm_mixed1.cc | 88 ++++ .../headers/algorithm/parallel_algorithm_mixed2.cc | 93 ++++ .../25_algorithms/headers/algorithm/synopsis.cc | 583 +++++++++++++++++++++ .../25_algorithms/headers/cstdlib/functions_std.cc | 26 + libstdc++-v3/testsuite/25_algorithms/heap/1.cc | 145 +++++ .../testsuite/25_algorithms/heap/moveable.cc | 156 ++++++ .../testsuite/25_algorithms/heap/moveable2.cc | 157 ++++++ libstdc++-v3/testsuite/25_algorithms/includes/1.cc | 89 ++++ .../testsuite/25_algorithms/includes/check_type.cc | 45 ++ .../requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 39 ++ .../testsuite/25_algorithms/inplace_merge/1.cc | 89 ++++ .../testsuite/25_algorithms/inplace_merge/49559.cc | 72 +++ .../25_algorithms/inplace_merge/check_type.cc | 47 ++ .../25_algorithms/inplace_merge/moveable.cc | 102 ++++ .../25_algorithms/inplace_merge/moveable2.cc | 102 ++++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ libstdc++-v3/testsuite/25_algorithms/is_heap/1.cc | 51 ++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/is_heap_until/1.cc | 51 ++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ .../testsuite/25_algorithms/is_partitioned/1.cc | 80 +++ .../25_algorithms/is_partitioned/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/is_permutation/1.cc | 104 ++++ .../25_algorithms/is_permutation/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ .../testsuite/25_algorithms/is_sorted/1.cc | 51 ++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/is_sorted_until/1.cc | 51 ++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ .../testsuite/25_algorithms/iter_swap/20577.cc | 70 +++ .../requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ .../25_algorithms/lexicographical_compare/1.cc | 85 +++ .../lexicographical_compare/check_type.cc | 50 ++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ .../testsuite/25_algorithms/lower_bound/1.cc | 46 ++ .../testsuite/25_algorithms/lower_bound/2.cc | 80 +++ .../testsuite/25_algorithms/lower_bound/33613.cc | 36 ++ .../25_algorithms/lower_bound/check_type.cc | 43 ++ .../25_algorithms/lower_bound/no_operator_ne.cc | 31 ++ .../requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 39 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/max/1.cc | 43 ++ libstdc++-v3/testsuite/25_algorithms/max/2.cc | 77 +++ libstdc++-v3/testsuite/25_algorithms/max/3.cc | 47 ++ libstdc++-v3/testsuite/25_algorithms/max/37547.cc | 39 ++ libstdc++-v3/testsuite/25_algorithms/max/4.cc | 54 ++ .../max/requirements/explicit_instantiation/2.cc | 39 ++ .../max/requirements/explicit_instantiation/3.cc | 38 ++ .../max/requirements/explicit_instantiation/pod.cc | 38 ++ .../requirements/explicit_instantiation/pod2.cc | 38 ++ .../testsuite/25_algorithms/max_element/1.cc | 70 +++ .../25_algorithms/max_element/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ libstdc++-v3/testsuite/25_algorithms/merge/1.cc | 100 ++++ .../testsuite/25_algorithms/merge/check_type.cc | 45 ++ .../merge/requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 39 ++ libstdc++-v3/testsuite/25_algorithms/min/1.cc | 43 ++ libstdc++-v3/testsuite/25_algorithms/min/2.cc | 86 +++ libstdc++-v3/testsuite/25_algorithms/min/3.cc | 47 ++ libstdc++-v3/testsuite/25_algorithms/min/37547.cc | 39 ++ libstdc++-v3/testsuite/25_algorithms/min/4.cc | 55 ++ .../min/requirements/explicit_instantiation/2.cc | 38 ++ .../min/requirements/explicit_instantiation/3.cc | 38 ++ .../min/requirements/explicit_instantiation/pod.cc | 37 ++ .../requirements/explicit_instantiation/pod2.cc | 38 ++ .../testsuite/25_algorithms/min_element/1.cc | 70 +++ .../25_algorithms/min_element/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ libstdc++-v3/testsuite/25_algorithms/minmax/1.cc | 49 ++ libstdc++-v3/testsuite/25_algorithms/minmax/2.cc | 61 +++ libstdc++-v3/testsuite/25_algorithms/minmax/3.cc | 55 ++ .../testsuite/25_algorithms/minmax/37547.cc | 39 ++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/3.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ .../requirements/explicit_instantiation/pod2.cc | 39 ++ .../testsuite/25_algorithms/minmax_element/1.cc | 138 +++++ .../25_algorithms/minmax_element/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc | 88 ++++ .../testsuite/25_algorithms/mismatch/check_type.cc | 50 ++ libstdc++-v3/testsuite/25_algorithms/move/1.cc | 62 +++ .../25_algorithms/move/deque_iterators/1.cc | 53 ++ .../move/requirements/explicit_instantiation/2.cc | 35 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../testsuite/25_algorithms/move_backward/1.cc | 64 +++ .../move_backward/deque_iterators/1.cc | 54 ++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/next_permutation/1.cc | 83 +++ .../25_algorithms/next_permutation/check_type.cc | 43 ++ .../25_algorithms/next_permutation/moveable.cc | 125 +++++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/none_of/1.cc | 70 +++ .../testsuite/25_algorithms/none_of/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/nth_element/1.cc | 81 +++ .../testsuite/25_algorithms/nth_element/2.cc | 80 +++ .../testsuite/25_algorithms/nth_element/3.cc | 86 +++ .../25_algorithms/nth_element/check_type.cc | 44 ++ .../25_algorithms/nth_element/moveable.cc | 106 ++++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/partial_sort/1.cc | 65 +++ .../testsuite/25_algorithms/partial_sort/2.cc | 84 +++ .../partial_sort/check_compare_by_value.cc | 93 ++++ .../25_algorithms/partial_sort/check_type.cc | 48 ++ .../25_algorithms/partial_sort/moveable.cc | 96 ++++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/partial_sort_copy/1.cc | 88 ++++ .../testsuite/25_algorithms/partial_sort_copy/2.cc | 91 ++++ .../25_algorithms/partial_sort_copy/check_type.cc | 67 +++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ .../testsuite/25_algorithms/partition/1.cc | 57 ++ .../testsuite/25_algorithms/partition/moveable.cc | 93 ++++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/partition_copy/1.cc | 106 ++++ .../25_algorithms/partition_copy/check_type.cc | 70 +++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ .../testsuite/25_algorithms/partition_point/1.cc | 85 +++ .../25_algorithms/partition_point/check_type.cc | 49 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../testsuite/25_algorithms/prev_permutation/1.cc | 83 +++ .../25_algorithms/prev_permutation/check_type.cc | 43 ++ .../25_algorithms/prev_permutation/moveable.cc | 125 +++++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/random_shuffle/1.cc | 74 +++ .../25_algorithms/random_shuffle/moveable.cc | 89 ++++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ libstdc++-v3/testsuite/25_algorithms/remove/1.cc | 62 +++ .../testsuite/25_algorithms/remove/check_type.cc | 38 ++ .../testsuite/25_algorithms/remove/moveable.cc | 71 +++ .../requirements/explicit_instantiation/2.cc | 35 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ .../requirements/explicit_instantiation/2.cc | 35 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../25_algorithms/remove_copy_if/check_type.cc | 58 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/remove_if/1.cc | 65 +++ .../25_algorithms/remove_if/check_type.cc | 49 ++ .../testsuite/25_algorithms/remove_if/moveable.cc | 71 +++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ libstdc++-v3/testsuite/25_algorithms/replace/1.cc | 60 +++ .../testsuite/25_algorithms/replace/check_type.cc | 37 ++ .../requirements/explicit_instantiation/2.cc | 35 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../testsuite/25_algorithms/replace_copy/1.cc | 71 +++ .../25_algorithms/replace_copy/check_type.cc | 55 ++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/replace_copy_if/1.cc | 75 +++ .../25_algorithms/replace_copy_if/check_type.cc | 55 ++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/replace_if/1.cc | 64 +++ .../25_algorithms/replace_if/check_type.cc | 51 ++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/reverse/moveable.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ .../reverse_copy/explicit_instantiation/2.cc | 35 ++ .../reverse_copy/explicit_instantiation/pod.cc | 35 ++ libstdc++-v3/testsuite/25_algorithms/rotate/1.cc | 125 +++++ .../testsuite/25_algorithms/rotate/check_type.cc | 47 ++ .../testsuite/25_algorithms/rotate/moveable.cc | 82 +++ .../testsuite/25_algorithms/rotate/moveable2.cc | 79 +++ .../requirements/explicit_instantiation/2.cc | 34 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ .../testsuite/25_algorithms/rotate/rotate.cc | 79 +++ .../requirements/explicit_instantiation/2.cc | 35 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ libstdc++-v3/testsuite/25_algorithms/search/1.cc | 162 ++++++ .../testsuite/25_algorithms/search/check_type.cc | 72 +++ .../requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 39 ++ .../testsuite/25_algorithms/search_n/11400.cc | 31 ++ .../testsuite/25_algorithms/search_n/check_type.cc | 38 ++ .../testsuite/25_algorithms/search_n/iterator.cc | 111 ++++ .../requirements/explicit_instantiation/2.cc | 41 ++ .../requirements/explicit_instantiation/pod.cc | 40 ++ .../testsuite/25_algorithms/set_difference/1.cc | 131 +++++ .../25_algorithms/set_difference/35541.cc | 36 ++ .../25_algorithms/set_difference/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 42 ++ .../requirements/explicit_instantiation/pod.cc | 41 ++ .../testsuite/25_algorithms/set_intersection/1.cc | 131 +++++ .../25_algorithms/set_intersection/34730.cc | 51 ++ .../25_algorithms/set_intersection/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 42 ++ .../requirements/explicit_instantiation/pod.cc | 41 ++ .../25_algorithms/set_symmetric_difference/1.cc | 133 +++++ .../set_symmetric_difference/check_type.cc | 44 ++ .../requirements/explicit_instantiation/2.cc | 42 ++ .../requirements/explicit_instantiation/pod.cc | 41 ++ .../testsuite/25_algorithms/set_union/1.cc | 136 +++++ .../25_algorithms/set_union/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 39 ++ libstdc++-v3/testsuite/25_algorithms/shuffle/1.cc | 67 +++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ libstdc++-v3/testsuite/25_algorithms/sort/1.cc | 85 +++ libstdc++-v3/testsuite/25_algorithms/sort/34095.cc | 32 ++ libstdc++-v3/testsuite/25_algorithms/sort/34636.cc | 32 ++ libstdc++-v3/testsuite/25_algorithms/sort/35588.cc | 31 ++ .../25_algorithms/sort/check_compare_by_value.cc | 86 +++ .../testsuite/25_algorithms/sort/moveable.cc | 84 +++ .../sort/requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/sort/vectorbool.cc | 43 ++ .../sort_heap/check_compare_by_value.cc | 88 ++++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/stable_partition/1.cc | 55 ++ .../25_algorithms/stable_partition/mem_check.cc | 71 +++ .../25_algorithms/stable_partition/moveable.cc | 88 ++++ .../25_algorithms/stable_partition/pr52822.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 36 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../testsuite/25_algorithms/stable_sort/1.cc | 89 ++++ .../testsuite/25_algorithms/stable_sort/2.cc | 88 ++++ .../testsuite/25_algorithms/stable_sort/49559.cc | 68 +++ .../stable_sort/check_compare_by_value.cc | 90 ++++ .../25_algorithms/stable_sort/check_type.cc | 48 ++ .../25_algorithms/stable_sort/mem_check.cc | 103 ++++ .../25_algorithms/stable_sort/moveable.cc | 63 +++ .../25_algorithms/stable_sort/moveable2.cc | 66 +++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc | 46 ++ .../swap/requirements/explicit_instantiation/2.cc | 33 ++ .../requirements/explicit_instantiation/pod.cc | 34 ++ .../testsuite/25_algorithms/swap_ranges/1.cc | 59 +++ .../25_algorithms/swap_ranges/check_type.cc | 34 ++ .../25_algorithms/swap_ranges/moveable.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 35 ++ .../requirements/explicit_instantiation/pod.cc | 35 ++ .../requirements/explicit_instantiation/2.cc | 40 ++ .../requirements/explicit_instantiation/pod.cc | 39 ++ libstdc++-v3/testsuite/25_algorithms/unique/1.cc | 32 ++ .../testsuite/25_algorithms/unique/11480.cc | 45 ++ libstdc++-v3/testsuite/25_algorithms/unique/2.cc | 94 ++++ .../testsuite/25_algorithms/unique/moveable.cc | 110 ++++ .../requirements/explicit_instantiation/2.cc | 37 ++ .../requirements/explicit_instantiation/pod.cc | 36 ++ .../testsuite/25_algorithms/unique_copy/1.cc | 84 +++ .../testsuite/25_algorithms/unique_copy/2.cc | 85 +++ .../testsuite/25_algorithms/unique_copy/26133.cc | 50 ++ .../25_algorithms/unique_copy/check_type.cc | 54 ++ .../requirements/explicit_instantiation/2.cc | 38 ++ .../requirements/explicit_instantiation/pod.cc | 37 ++ .../testsuite/25_algorithms/upper_bound/1.cc | 46 ++ .../testsuite/25_algorithms/upper_bound/2.cc | 80 +++ .../testsuite/25_algorithms/upper_bound/33613.cc | 36 ++ .../25_algorithms/upper_bound/check_type.cc | 43 ++ .../requirements/explicit_instantiation/2.cc | 39 ++ .../requirements/explicit_instantiation/pod.cc | 38 ++ 405 files changed, 22062 insertions(+) create mode 100644 libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/binary_search/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/34595.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/move_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count_if/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal/no_operator_ne.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal_range/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/35725.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill_n/25306.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/17441.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/39546.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_end/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_first_of/concept_check_1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/for_each/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/generate_n/25306.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/headers/algorithm/algorithm_parallel_mode.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/headers/cstdlib/functions_std.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/heap/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/heap/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/includes/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/49559.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_heap/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_heap_until/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_partitioned/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_partitioned/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_permutation/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/iter_swap/20577.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/33613.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/no_operator_ne.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/37547.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max_element/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/merge/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/37547.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/4.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min_element/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax_element/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax_element/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move_backward/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/next_permutation/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/3.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/check_compare_by_value.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_copy/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_copy/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_point/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_point/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/prev_permutation/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/reverse/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_difference/35541.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_intersection/34730.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_union/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/shuffle/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/34095.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/34636.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/35588.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/check_compare_by_value.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort/vectorbool.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort_heap/check_compare_by_value.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_partition/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_partition/mem_check.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/49559.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/check_compare_by_value.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/mem_check.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap_ranges/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique/11480.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique/moveable.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique_copy/26133.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/pod.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/upper_bound/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/upper_bound/33613.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/pod.cc (limited to 'libstdc++-v3/testsuite/25_algorithms') diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc new file mode 100644 index 000000000..ab8d22bda --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.5 [lib.alg.adjacent_find] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::adjacent_find; + +typedef test_container Container; +int array[] = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; + +void +test01() +{ + Container con(array, array); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array); +} + +void +test02() +{ + Container con(array, array + 1); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array + 1); +} + +void +test03() +{ + Container con(array, array + 2); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array); +} + +void +test04() +{ + Container con(array + 1, array + 10); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array + 10); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc new file mode 100644 index 000000000..b0d34e0d8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.5 [lib.alg.adjacent_find] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator==(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& s) +{ return std::adjacent_find(s, s); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x) +{ return std::adjacent_find(x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ea3a7ee1e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type adjacent_find(iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..7b69d2fad --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type adjacent_find(iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/1.cc new file mode 100644 index 000000000..318fffa6e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/1.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 0; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::all_of(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::all_of(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( !std::all_of(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc new file mode 100644 index 000000000..cf39952be --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/check_type.cc @@ -0,0 +1,49 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::all_of(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::all_of(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ca06ac332 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool all_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..1858332c3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/all_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool all_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/1.cc new file mode 100644 index 000000000..f32d8579f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/1.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( !std::any_of(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( !std::any_of(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( std::any_of(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc new file mode 100644 index 000000000..557dc21e6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/check_type.cc @@ -0,0 +1,49 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::any_of(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::any_of(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..2560dfc01 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool any_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..4a22c69b7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/any_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool any_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc new file mode 100644 index 000000000..2a5eb63c1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.4 [lib.binary.search] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::binary_search; + +typedef test_container Container; + +void +test1() +{ + int array[] = {0}; + Container con(array, array); + VERIFY(!binary_search(con.begin(), con.end(), 1)); +} + +void +test2() +{ + int array[] = {0, 2, 4, 6, 8}; + Container con(array, array + 5); + for(int i = 0; i < 10; i += 2) + VERIFY(binary_search(con.begin(), con.end(), i)); + for(int i = -1; i < 11; i += 2) + VERIFY(!binary_search(con.begin(), con.end(), i)); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/2.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/2.cc new file mode 100644 index 000000000..19d227215 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/2.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2001, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3 [lib.alg.binary.search] Binary search algorithms. + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 3, 3, 5, 8}; +const int C[] = {8, 5, 3, 3, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); + +// A comparison, equalivalent to std::greater without the +// dependency on . +struct gt +{ + bool + operator()(const int& x, const int& y) const + { return x > y; } +}; + +// 25.3.3.4 binary_search, with and without comparison predicate +void +test04() +{ + using std::binary_search; + + const int first = A[0]; + const int last = A[N - 1]; + + VERIFY(binary_search(A, A + N, 5)); + VERIFY(binary_search(A, A + N, first)); + VERIFY(binary_search(A, A + N, last)); + VERIFY(!binary_search(A, A + N, 4)); + + VERIFY(binary_search(C, C + N, 5, gt())); + VERIFY(binary_search(C, C + N, first, gt())); + VERIFY(binary_search(C, C + N, last, gt())); + VERIFY(!binary_search(C, C + N, 4, gt())); +} + +int +main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc new file mode 100644 index 000000000..90ed04672 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.4 [lib.binary.search] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator<(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +bool +test1(forward_iterator_wrapper& s) +{ return std::binary_search(s, s, *s); } + +bool +test2(forward_iterator_wrapper& x) +{ return std::binary_search(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..07519f234 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool binary_search(iterator_type, iterator_type, const value_type&); + + template bool binary_search(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..08552cb02 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool binary_search(iterator_type, iterator_type, const value_type&); + + template bool binary_search(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy/1.cc new file mode 100644 index 000000000..d73c15427 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2001, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.1 [lib.alg.copy] Copy. + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + + int i1[N]; + copy(A, A + N, i1); + VERIFY( equal(i1, i1 + N, A) ); + + vector v1(N); + copy(A, A + N, v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), A) ); + + short s1[N]; + copy(A, A + N, s1); + VERIFY( equal(s1, s1 + N, A) ); + + int i2[N]; + copy_backward(A, A + N, i2 + N); + VERIFY( equal(i2, i2 + N, A) ); + + vector v2(N); + copy_backward(A, A + N, v2.end()); + VERIFY( equal(v2.begin(), v2.end(), A) ); + + short s2[N]; + copy_backward(A, A + N, s2 + N); + VERIFY( equal(s2, s2 + N, A) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy/2.cc new file mode 100644 index 000000000..08d3f5994 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/2.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.1 [lib.alg.copy] Copy. + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + const vector a(A, A + N); + + int i1[N]; + copy(a.begin(), a.end(), i1); + VERIFY( equal(i1, i1 + N, a.begin()) ); + + vector v1(N); + copy(a.begin(), a.end(), v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), a.begin()) ); + + short s1[N]; + copy(a.begin(), a.end(), s1); + VERIFY( equal(s1, s1 + N, a.begin()) ); + + int i2[N]; + copy_backward(a.begin(), a.end(), i2 + N); + VERIFY( equal(i2, i2 + N, a.begin()) ); + + vector v2(N); + copy_backward(a.begin(), a.end(), v2.end()); + VERIFY( equal(v2.begin(), v2.end(), a.begin()) ); + + short s2[N]; + copy_backward(a.begin(), a.end(), s2 + N); + VERIFY( equal(s2, s2 + N, a.begin()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/3.cc b/libstdc++-v3/testsuite/25_algorithms/copy/3.cc new file mode 100644 index 000000000..29caf3ae9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/3.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.1 [lib.alg.copy] Copy. + +#include +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + const deque a(A, A + N); + + int i1[N]; + copy(a.begin(), a.end(), i1); + VERIFY( equal(i1, i1 + N, a.begin()) ); + + vector v1(N); + copy(a.begin(), a.end(), v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), a.begin()) ); + + short s1[N]; + copy(a.begin(), a.end(), s1); + VERIFY( equal(s1, s1 + N, a.begin()) ); + + int i2[N]; + copy_backward(a.begin(), a.end(), i2 + N); + VERIFY( equal(i2, i2 + N, a.begin()) ); + + vector v2(N); + copy_backward(a.begin(), a.end(), v2.end()); + VERIFY( equal(v2.begin(), v2.end(), a.begin()) ); + + short s2[N]; + copy_backward(a.begin(), a.end(), s2 + N); + VERIFY( equal(s2, s2 + N, a.begin()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc b/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc new file mode 100644 index 000000000..612eb4872 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/34595.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.1 [lib.alg.copy] Copy. + +#include +#include + +class Counting_output_iterator +: public std::iterator< std::output_iterator_tag, void, void, void, void > +{ + std::size_t c; +public: + Counting_output_iterator() : c(0) {} + Counting_output_iterator& operator++() { return *this; } + Counting_output_iterator& operator*() { return *this; } + + template + void operator=(const T&) { ++c; } + + std::size_t current_counter() const { return c; } +}; + +// libstdc++/34595 +void test01() +{ + bool test __attribute__((unused)) = true; + + int t[10] = {0,}; + Counting_output_iterator cnt; + std::size_t res = std::copy(t+0, t+5, cnt).current_counter(); + + VERIFY( res == 5 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/4.cc b/libstdc++-v3/testsuite/25_algorithms/copy/4.cc new file mode 100644 index 000000000..885561a2b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/4.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.1 [lib.alg.copy] Copy. + +#include +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + const list a(A, A + N); + + int i1[N]; + copy(a.begin(), a.end(), i1); + VERIFY( equal(i1, i1 + N, a.begin()) ); + + vector v1(N); + copy(a.begin(), a.end(), v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), a.begin()) ); + + short s1[N]; + copy(a.begin(), a.end(), s1); + VERIFY( equal(s1, s1 + N, a.begin()) ); + + int i2[N]; + copy_backward(a.begin(), a.end(), i2 + N); + VERIFY( equal(i2, i2 + N, a.begin()) ); + + vector v2(N); + copy_backward(a.begin(), a.end(), v2.end()); + VERIFY( equal(v2.begin(), v2.end(), a.begin()) ); + + short s2[N]; + copy_backward(a.begin(), a.end(), s2 + N); + VERIFY( equal(s2, s2 + N, a.begin()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/1.cc new file mode 100644 index 000000000..172c2aed2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/deque_iterators/1.cc @@ -0,0 +1,51 @@ +// 2009-12-23 Paolo Carlini +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque data(200); + for (unsigned i = 0; i < data.size(); ++i) + data[i] = i; + + const deque data_1(data.size(), -1); + + for (unsigned i = 0; i < data.size(); i += 2) + for (unsigned j = i; j <= data.size(); j += 3) + for (unsigned k = 0; k + (j - i) <= data.size(); k += 5) + { + deque d(data.size(), -1); + copy(data.begin() + i, data.begin() + j, d.begin() + k); + + VERIFY( equal(data.begin() + i, data.begin() + j, + d.begin() + k) ); + VERIFY( equal(d.begin(), d.begin() + k, data_1.begin()) ); + VERIFY( equal(d.begin() + k + (j - i), d.end(), data_1.begin()) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/1.cc new file mode 100644 index 000000000..4781ba1de --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/1.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::copy; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + copy(std::move_iterator >(incon.begin()), + std::move_iterator >(incon.end()), + outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..720cc767b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type copy(iterator_type, iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..343d8027b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type copy(iterator_type, iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/1.cc new file mode 100644 index 000000000..ab66f7251 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/1.cc @@ -0,0 +1,75 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + typedef ostreambuf_iterator out_iterator_type; + + const char data1[] = "Drei Phantasien nach Friedrich Holderlin"; + const string str1(data1); + istringstream iss1(str1); + in_iterator_type beg1(iss1); + in_iterator_type end1; + + ostringstream oss1; + out_iterator_type out1(oss1); + + out1 = copy(beg1, beg1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(end1, end1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = 'x'; + VERIFY( oss1.str() == str1 + 'x' ); + oss1.str(""); + + iss1.seekg(0); + oss1.seekp(0); + oss1.str(""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = 'y'; + VERIFY( oss1.str() == str1 + 'y' ); + oss1.str(""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == "" ); + + iss1.seekg(0); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/2.cc new file mode 100644 index 000000000..201e27871 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/2.cc @@ -0,0 +1,77 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + const char data1[] = "Drei Phantasien nach Friedrich Holderlin"; + const string str1(data1); + istringstream iss1(str1); + in_iterator_type beg1(iss1); + in_iterator_type end1; + + char buffer1[sizeof(data1) * 5]; + memset(buffer1, '*', sizeof(buffer1)); + char* out1 = buffer1; + + out1 = copy(beg1, beg1, out1); + VERIFY( out1 == buffer1 ); + + out1 = copy(end1, end1, out1); + VERIFY( out1 == buffer1 ); + + out1 = copy(beg1, end1, out1); + VERIFY( string(buffer1, out1) == str1 ); + *out1++ = 'x'; + VERIFY( string(buffer1, out1) == str1 + 'x' ); + memset(buffer1, '*', sizeof(buffer1)); + + iss1.seekg(0); + out1 = buffer1; + memset(buffer1, '*', sizeof(buffer1)); + out1 = copy(beg1, end1, out1); + VERIFY( string(buffer1, out1) == str1 ); + *out1++ = 'y'; + VERIFY( string(buffer1, out1) == str1 + 'y' ); + out1 = buffer1; + memset(buffer1, '*', sizeof(buffer1)); + out1 = copy(beg1, end1, out1); + VERIFY( string(buffer1, out1) == "" ); + + iss1.seekg(0); + out1 = copy(beg1, end1, out1); + VERIFY( string(buffer1, out1) == str1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/3.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/3.cc new file mode 100644 index 000000000..d8f5dbfc6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/3.cc @@ -0,0 +1,71 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef ostreambuf_iterator out_iterator_type; + + const char data1[] = "Drei Phantasien nach Friedrich Holderlin"; + const string str1(data1); + const char* beg1 = data1; + const char* end1 = beg1 + str1.size(); + + ostringstream oss1; + out_iterator_type out1(oss1); + + out1 = copy(beg1, beg1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(end1, end1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = 'x'; + VERIFY( oss1.str() == str1 + 'x' ); + oss1.str(""); + + oss1.seekp(0); + oss1.str(""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = 'y'; + VERIFY( oss1.str() == str1 + 'y' ); + oss1.str(""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 + str1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc new file mode 100644 index 000000000..62ecf686d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc @@ -0,0 +1,58 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include +#include + +// { dg-require-fileio "" } + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + ifstream fbuf_ref("istream_unformatted-1.txt"), + fbuf("istream_unformatted-1.txt"); + + char buffer_ref[16500], + buffer[16500]; + + fbuf_ref.read(buffer_ref, 16500); + + in_iterator_type beg(fbuf); + in_iterator_type end; + copy(beg, end, buffer); + + VERIFY( fbuf_ref.good() ); + VERIFY( fbuf.good() ); + + VERIFY( !memcmp(buffer, buffer_ref, 16500) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/1.cc new file mode 100644 index 000000000..655b3242d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/1.cc @@ -0,0 +1,75 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + typedef ostreambuf_iterator out_iterator_type; + + const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin"; + const wstring str1(data1); + wistringstream iss1(str1); + in_iterator_type beg1(iss1); + in_iterator_type end1; + + wostringstream oss1; + out_iterator_type out1(oss1); + + out1 = copy(beg1, beg1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(end1, end1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = L'x'; + VERIFY( oss1.str() == str1 + L'x' ); + oss1.str(L""); + + iss1.seekg(0); + oss1.seekp(0); + oss1.str(L""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = L'y'; + VERIFY( oss1.str() == str1 + L'y' ); + oss1.str(L""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == L"" ); + + iss1.seekg(0); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/2.cc new file mode 100644 index 000000000..d7871320b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/2.cc @@ -0,0 +1,76 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin"; + const wstring str1(data1); + wistringstream iss1(str1); + in_iterator_type beg1(iss1); + in_iterator_type end1; + + wchar_t buffer1[sizeof(data1) * 5 / sizeof(wchar_t)]; + wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t)); + wchar_t* out1 = buffer1; + + out1 = copy(beg1, beg1, out1); + VERIFY( out1 == buffer1 ); + + out1 = copy(end1, end1, out1); + VERIFY( out1 == buffer1 ); + + out1 = copy(beg1, end1, out1); + VERIFY( wstring(buffer1, out1) == str1 ); + *out1++ = L'x'; + VERIFY( wstring(buffer1, out1) == str1 + L'x' ); + wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t)); + + iss1.seekg(0); + out1 = buffer1; + wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t)); + out1 = copy(beg1, end1, out1); + VERIFY( wstring(buffer1, out1) == str1 ); + *out1++ = L'y'; + VERIFY( wstring(buffer1, out1) == str1 + L'y' ); + out1 = buffer1; + wmemset(buffer1, L'*', sizeof(buffer1) / sizeof(wchar_t)); + out1 = copy(beg1, end1, out1); + VERIFY( wstring(buffer1, out1) == L"" ); + + iss1.seekg(0); + out1 = copy(beg1, end1, out1); + VERIFY( wstring(buffer1, out1) == str1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/3.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/3.cc new file mode 100644 index 000000000..ac50b87de --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/3.cc @@ -0,0 +1,71 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef ostreambuf_iterator out_iterator_type; + + const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin"; + const wstring str1(data1); + const wchar_t* beg1 = data1; + const wchar_t* end1 = beg1 + str1.size(); + + wostringstream oss1; + out_iterator_type out1(oss1); + + out1 = copy(beg1, beg1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(end1, end1, out1); + VERIFY( oss1.str().empty() ); + + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = L'x'; + VERIFY( oss1.str() == str1 + L'x' ); + oss1.str(L""); + + oss1.seekp(0); + oss1.str(L""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + *out1 = L'y'; + VERIFY( oss1.str() == str1 + L'y' ); + oss1.str(L""); + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 ); + + out1 = copy(beg1, end1, out1); + VERIFY( oss1.str() == str1 + str1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc new file mode 100644 index 000000000..56a5cdef6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc @@ -0,0 +1,55 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + wifstream fbuf_ref("istream_unformatted-1.txt"), + fbuf("istream_unformatted-1.txt"); + + wchar_t buffer_ref[16500], + buffer[16500]; + + fbuf_ref.read(buffer_ref, 16500); + + in_iterator_type beg(fbuf); + in_iterator_type end; + copy(beg, end, buffer); + + VERIFY( fbuf_ref.good() ); + VERIFY( fbuf.good() ); + + VERIFY( !wmemcmp(buffer, buffer_ref, 16500) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/1.cc new file mode 100644 index 000000000..211de8129 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/deque_iterators/1.cc @@ -0,0 +1,52 @@ +// 2009-12-24 Paolo Carlini +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque data(200); + for (unsigned i = 0; i < data.size(); ++i) + data[i] = i; + + const deque data_1(data.size(), -1); + + for (unsigned i = 0; i < data.size(); i += 2) + for (unsigned j = i; j <= data.size(); j += 3) + for (unsigned k = 0; k + (j - i) <= data.size(); k += 5) + { + deque d(data.size(), -1); + copy_backward(data.begin() + i, data.begin() + j, + d.begin() + k + (j - i)); + + VERIFY( equal(data.begin() + i, data.begin() + j, + d.begin() + k) ); + VERIFY( equal(d.begin(), d.begin() + k, data_1.begin()) ); + VERIFY( equal(d.begin() + k + (j - i), d.end(), data_1.begin()) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/1.cc new file mode 100644 index 000000000..2f697b0b3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/move_iterators/1.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::copy_backward; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + std::fill(out, out + size, 0); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + copy_backward(std::move_iterator >(incon.begin()), + std::move_iterator >(incon.end()), + outcon.end()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..b3bd8b4b7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + template iterator_type copy_backward(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..39a0bff8c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_backward/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + template iterator_type copy_backward(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc new file mode 100644 index 000000000..b132227f1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_if/check_type.cc @@ -0,0 +1,59 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Z +{ + Z& + operator=(const X&) + { return *this; } +}; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +output_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::copy_if(begin, end, output, pred_function); } + +output_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::copy_if(begin, end, output, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..17c3dda6c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-24 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type copy_if(iterator_type, iterator_type, + iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..22f4c33b2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-24 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type copy_if(iterator_type, iterator_type, + iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/1.cc new file mode 100644 index 000000000..85c5db792 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/1.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + + int i1[N]; + copy_n(A, N, i1); + VERIFY( equal(i1, i1 + N, A) ); + + vector v1(N); + copy_n(A, N, v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), A) ); + + short s1[N]; + copy_n(A, N, s1); + VERIFY( equal(s1, s1 + N, A) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/2.cc new file mode 100644 index 000000000..8d3411bad --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/2.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + const vector a(A, A + N); + + int i1[N]; + copy_n(a.begin(), N, i1); + VERIFY( equal(i1, i1 + N, a.begin()) ); + + vector v1(N); + copy_n(a.begin(), N, v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), a.begin()) ); + + short s1[N]; + copy_n(a.begin(), N, s1); + VERIFY( equal(s1, s1 + N, a.begin()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/3.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/3.cc new file mode 100644 index 000000000..75d139b8f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/3.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + const deque a(A, A + N); + + int i1[N]; + copy_n(a.begin(), N, i1); + VERIFY( equal(i1, i1 + N, a.begin()) ); + + vector v1(N); + copy_n(a.begin(), N, v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), a.begin()) ); + + short s1[N]; + copy_n(a.begin(), N, s1); + VERIFY( equal(s1, s1 + N, a.begin()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/4.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/4.cc new file mode 100644 index 000000000..21a95a076 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/4.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int N = sizeof(A) / sizeof(int); + const list a(A, A + N); + + int i1[N]; + copy_n(a.begin(), N, i1); + VERIFY( equal(i1, i1 + N, a.begin()) ); + + vector v1(N); + copy_n(a.begin(), N, v1.begin()); + VERIFY( equal(v1.begin(), v1.end(), a.begin()) ); + + short s1[N]; + copy_n(a.begin(), N, s1); + VERIFY( equal(s1, s1 + N, a.begin()) ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/move_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/move_iterators/1.cc new file mode 100644 index 000000000..2db2479bd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/move_iterators/1.cc @@ -0,0 +1,65 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::copy_n; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + copy_n(std::move_iterator >(incon.begin()), + size, outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..d04ae4690 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-29 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + template iterator_type copy_n(iterator_type, size_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..13e717b54 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-24 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + template iterator_type copy_n(iterator_type, size_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count/1.cc b/libstdc++-v3/testsuite/25_algorithms/count/1.cc new file mode 100644 index 000000000..852befe2a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.6 count + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + VERIFY(std::count(con.begin(), con.end(), 1) == 0); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::count(con.begin(), con.end(), 1) == 0); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::count(con.begin(), con.end(), 1) == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc new file mode 100644 index 000000000..9e64b3015 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.2 find_if + +// { dg-do compile } + +#include +#include + +struct X { }; + +struct Y { }; + +using __gnu_test::input_iterator_wrapper; + +bool +operator==(const X&, const Y&) +{ return true; } + +typedef std::iterator_traits >::difference_type + diff_type; + +diff_type +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::count(begin, end, Y()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..13dfb7919 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef iterator_traits::difference_type difference_type; + + template difference_type count(iterator_type, iterator_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..6010a359f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef iterator_traits::difference_type difference_type; + + template difference_type count(iterator_type, iterator_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc new file mode 100644 index 000000000..b42e23d1a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.6 count_if + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 0); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 0); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc new file mode 100644 index 000000000..68e80767e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.2 find_if + +// { dg-do compile } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +typedef std::iterator_traits >::difference_type + diff_type; + +diff_type +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::count_if(begin, end, pred_function); } + +diff_type +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::count_if(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..6d0cbd1b9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::iterator_traits::difference_type difference_type; + typedef std::pointer_to_unary_function predicate_type; + + template difference_type count_if(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..3080b25c7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::iterator_traits::difference_type difference_type; + typedef std::pointer_to_unary_function predicate_type; + + template difference_type count_if(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc new file mode 100644 index 000000000..2b0ddaa43 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0}; + +void test1() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::equal(con1.begin(), con1.end(), con2.begin()) ); +} + +void test2() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) ); +} + +void test3() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) ); +} + +void test4() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con1.begin(), con1.end(), con2.begin()) ); +} + +void test5() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::equal(con3.begin(), con3.end(), con2.begin()) ); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc new file mode 100644 index 000000000..005733048 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.8 [lib.alg.equal] + +// { dg-do compile } + +#include +#include +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct Lhs2 { }; + +struct Rhs2 { }; + +bool +predicate(const Lhs2&, const Rhs2&) {return true;} + +bool +test1(input_iterator_wrapper& lhs1, + input_iterator_wrapper& rhs1) +{ return std::equal(lhs1, lhs1, rhs1); } + +bool +test2(input_iterator_wrapper& lhs2, + input_iterator_wrapper& rhs2) +{ return std::equal(lhs2, lhs2, rhs2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/no_operator_ne.cc b/libstdc++-v3/testsuite/25_algorithms/equal/no_operator_ne.cc new file mode 100644 index 000000000..42b70e151 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/no_operator_ne.cc @@ -0,0 +1,39 @@ +// 2001-04-06 gdr + +// Copyright (C) 2000, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// +// 25.1.8 Make sure std::equal doesn't make any extra assumption +// about operator== and operator!= +// + +struct X { }; + +bool operator==(X, X) { return true; } + +// Not implemented on purpose. { dg-do link } +bool operator!=(X, X); + +int main() +{ + std::vector v, w; + return !std::equal(v.begin(), v.end(), w.begin()); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..73c466a6d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + // template void fill_n(iterator_type, size_type, const value_type&); + template iterator_type fill_n(iterator_type, size_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..dc0c29a62 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + // template void fill_n(iterator_type, size_type, const value_type&); + template iterator_type fill_n(iterator_type, size_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc new file mode 100644 index 000000000..de09c79a5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.3 [lib.equal.range] + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::equal_range; + +typedef test_container Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; + +void +test1() +{ + for(int i = 0; i < 6; ++i) + for(int j = 6; j < 12; ++j) + { + Container con(array + i, array + j); + VERIFY(equal_range(con.begin(), con.end(), 1).first.ptr == + array + std::max(i, 4)); + VERIFY(equal_range(con.begin(), con.end(), 1).second.ptr == + array + std::min(j, 8)); + } +} + +void +test2() +{ + int array[]={0, 0, 2, 2, 2}; + Container con(array, array + 5); + VERIFY(equal_range(con.begin(), con.end(), 1).first.ptr == + array + 2); + VERIFY(equal_range(con.begin(), con.end(), 1).second.ptr == + array + 2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/2.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/2.cc new file mode 100644 index 000000000..cbebd62db --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/2.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3 [lib.alg.binary.search] Binary search algorithms. + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 3, 3, 5, 8}; +const int C[] = {8, 5, 3, 3, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); + +// A comparison, equalivalent to std::greater without the +// dependency on . +struct gt +{ + bool + operator()(const int& x, const int& y) const + { return x > y; } +}; + +// Each test performs general-case, bookend, not-found condition, +// and predicate functional checks. + +// 25.3.3.3 equal_range, with and without comparison predicate +void +test03() +{ + using std::equal_range; + typedef std::pair Ipair; + + const int first = A[0]; + const int last = A[N - 1]; + + Ipair p = equal_range(A, A + N, 3); + VERIFY(p.first == A + 2); + VERIFY(p.second == A + 5); + + Ipair q = equal_range(A, A + N, first); + VERIFY(q.first == A + 0); + VERIFY(q.second == A + 1); + + Ipair r = equal_range(A, A + N, last); + VERIFY(r.first == A + N - 1); + VERIFY(r.second == A + N); + + Ipair s = equal_range(A, A + N, 4); + VERIFY(s.first == A + 5); + VERIFY(s.second == A + 5); + + Ipair t = equal_range(C, C + N, 3, gt()); + VERIFY(t.first == C + 2); + VERIFY(t.second == C + 5); + + Ipair u = equal_range(C, C + N, first, gt()); + VERIFY(u.first == C + N - 1); + VERIFY(u.second == C + N); + + Ipair v = equal_range(C, C + N, last, gt()); + VERIFY(v.first == C + 0); + VERIFY(v.second == C + 1); + + Ipair w = equal_range(C, C + N, 4, gt()); + VERIFY(w.first == C + 2); + VERIFY(w.second == C + 2); +} + +int +main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc new file mode 100644 index 000000000..f6b2629ec --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.3 [lib.equal.range] + +// { dg-do compile } + +#include +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator<(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +std::pair, forward_iterator_wrapper > +test1(forward_iterator_wrapper& s) +{ return std::equal_range(s, s, *s); } + +std::pair, forward_iterator_wrapper > +test2(forward_iterator_wrapper& x) +{ return std::equal_range(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..5d14c69f7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/2.cc @@ -0,0 +1,42 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pair pair_type; + typedef std::less compare_type; + + template pair_type equal_range(iterator_type, iterator_type, + const value_type&); + + template pair_type equal_range(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..34ddf77c0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,41 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pair pair_type; + typedef std::less compare_type; + + template pair_type equal_range(iterator_type, iterator_type, + const value_type&); + + template pair_type equal_range(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/1.cc b/libstdc++-v3/testsuite/25_algorithms/fill/1.cc new file mode 100644 index 000000000..46bf33e55 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/1.cc @@ -0,0 +1,63 @@ +// 2004-06-25 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill + +#include +#include +#include + +class num +{ + int stored; + +public: + num(int init = 0) + : stored(init) + { } + + operator int() const + { return stored; } +}; + +// fill +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + const int val = 1; + + const int V[] = { val, val, val, val, val, val, val }; + const list::size_type N = sizeof(V) / sizeof(int); + + list coll(N); + fill(coll.begin(), coll.end(), val); + VERIFY( equal(coll.begin(), coll.end(), V) ); + + list coll2(N); + fill(coll2.begin(), coll2.end(), val); + VERIFY( equal(coll2.begin(), coll2.end(), V) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/2.cc b/libstdc++-v3/testsuite/25_algorithms/fill/2.cc new file mode 100644 index 000000000..d02d1ad89 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/2.cc @@ -0,0 +1,63 @@ +// 2004-06-25 Paolo Carlini + +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill + +#include +#include +#include + +class num +{ + int stored; + +public: + num(int init = 0) + : stored(init) + { } + + operator int() const + { return stored; } +}; + +// fill_n +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + const int val = 3; + + const int V[] = { val, val, val, val, val, val, val, val, val }; + const list::size_type N = sizeof(V) / sizeof(int); + + list coll(N); + fill_n(coll.begin(), coll.size(), val); + VERIFY( equal(coll.begin(), coll.end(), V) ); + + list coll2(N); + fill_n(coll2.begin(), coll2.size(), val); + VERIFY( equal(coll2.begin(), coll2.end(), V) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/3.cc b/libstdc++-v3/testsuite/25_algorithms/fill/3.cc new file mode 100644 index 000000000..5ababcab1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/3.cc @@ -0,0 +1,41 @@ +// 2007-01-13 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + char ca[1] = { '\0' }; + signed char sc = 1; + + std::fill_n(ca, 1, sc); + VERIFY( ca[0] == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/35725.cc b/libstdc++-v3/testsuite/25_algorithms/fill/35725.cc new file mode 100644 index 000000000..bc3e20087 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/35725.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/35725 +void test01() +{ + std::vector foo(20); + std::fill(foo.begin(), foo.end(), "bar"); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/4.cc b/libstdc++-v3/testsuite/25_algorithms/fill/4.cc new file mode 100644 index 000000000..838a71720 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/4.cc @@ -0,0 +1,75 @@ +// 2007-01-19 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill. + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A1[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; + const int N1 = sizeof(A1) / sizeof(int); + + int i1[N1]; + fill(i1, i1 + N1, 3); + VERIFY( equal(i1, i1 + N1, A1) ); + + vector v1(N1); + fill(v1.begin(), v1.end(), 3); + VERIFY( equal(v1.begin(), v1.end(), A1) ); + + const char A2[] = {'\3', '\3', '\3', '\3', '\3', + '\3', '\3', '\3', '\3', '\3'}; + const int N2 = sizeof(A2) / sizeof(char); + + char i2[N2]; + fill(i2, i2 + N2, '\3'); + VERIFY( equal(i2, i2 + N2, A2) ); + + vector v2(N2); + fill(v2.begin(), v2.end(), '\3'); + VERIFY( equal(v2.begin(), v2.end(), A2) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + const wchar_t A3[] = {L'\3', L'\3', L'\3', L'\3', L'\3', + L'\3', L'\3', L'\3', L'\3', L'\3'}; + const int N3 = sizeof(A3) / sizeof(wchar_t); + + wchar_t i3[N3]; + fill(i3, i3 + N3, L'\3'); + VERIFY( equal(i3, i3 + N3, A3) ); + + vector v3(N3); + fill(v3.begin(), v3.end(), L'\3'); + VERIFY( equal(v3.begin(), v3.end(), A3) ); +#endif +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..95343d2ba --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template void fill(iterator_type, iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..5695c77da --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template void fill(iterator_type, iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc new file mode 100644 index 000000000..78a3c2312 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/1.cc @@ -0,0 +1,75 @@ +// 2007-01-19 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.5 [lib.alg.fill] Fill_n. + +#include +#include +#include + +void +test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + const int A1[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; + const int N1 = sizeof(A1) / sizeof(int); + + int i1[N1]; + fill_n(i1, N1, 3); + VERIFY( equal(i1, i1 + N1, A1) ); + + vector v1(N1); + fill_n(v1.begin(), N1, 3); + VERIFY( equal(v1.begin(), v1.end(), A1) ); + + const char A2[] = {'\3', '\3', '\3', '\3', '\3', + '\3', '\3', '\3', '\3', '\3'}; + const int N2 = sizeof(A2) / sizeof(char); + + char i2[N2]; + fill_n(i2, N2, '\3'); + VERIFY( equal(i2, i2 + N2, A2) ); + + vector v2(N2); + fill_n(v2.begin(), N2, '\3'); + VERIFY( equal(v2.begin(), v2.end(), A2) ); + +#ifdef _GLIBCXX_USE_WCHAR_T + const wchar_t A3[] = {L'\3', L'\3', L'\3', L'\3', L'\3', + L'\3', L'\3', L'\3', L'\3', L'\3'}; + const int N3 = sizeof(A3) / sizeof(wchar_t); + + wchar_t i3[N3]; + fill_n(i3, N3, L'\3'); + VERIFY( equal(i3, i3 + N3, A3) ); + + vector v3(N3); + fill_n(v3.begin(), N3, L'\3'); + VERIFY( equal(v3.begin(), v3.end(), A3) ); +#endif +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/25306.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/25306.cc new file mode 100644 index 000000000..37ccd7c36 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/25306.cc @@ -0,0 +1,30 @@ +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct Size +{ + operator int() { return 0; } +private: + void operator=(Size&); +}; + +// libstdc++/25306 +template int* std::fill_n(int*, Size, const int&); diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc new file mode 100644 index 000000000..5a6eeef5f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/35725.cc @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/35725 +void test01() +{ + std::vector foo(20); + std::fill_n(foo.begin(), 20, "bar"); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..73c466a6d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + // template void fill_n(iterator_type, size_type, const value_type&); + template iterator_type fill_n(iterator_type, size_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..dc0c29a62 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/fill_n/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + + // template void fill_n(iterator_type, size_type, const value_type&); + template iterator_type fill_n(iterator_type, size_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/1.cc b/libstdc++-v3/testsuite/25_algorithms/find/1.cc new file mode 100644 index 000000000..be8b1d6cd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.2 find + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 1); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/17441.cc b/libstdc++-v3/testsuite/25_algorithms/find/17441.cc new file mode 100644 index 000000000..e80477b1d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/17441.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, find() + +#include + +using namespace std; + +template + InputIterator + find(InputIterator first, InputIterator, + const Tp&, input_iterator_tag) + { return first; } + +// libstdc++/17441 +void test01() +{ + input_iterator_tag a; + int i; + find(&i, &i, 1, a); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/39546.cc b/libstdc++-v3/testsuite/25_algorithms/find/39546.cc new file mode 100644 index 000000000..b83a85534 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/39546.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, find() + +#include +#include +#include +#include + +// libstdc++/39546 +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector dict; + dict.push_back("one"); + dict.push_back("two"); + dict.push_back("three"); + + VERIFY( std::find(dict.begin(), dict.end(), "two") == dict.begin() + 1 ); +} + +int +main() +{ + test01(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc new file mode 100644 index 000000000..52007f20f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.2 find + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; + +struct Lhs { }; +struct Rhs { }; + +bool +operator==(const Lhs&, const Rhs&) +{ return true; } + +input_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, Rhs& val) +{ return std::find(begin, end, val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/1.cc b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/1.cc new file mode 100644 index 000000000..fca18d916 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/1.cc @@ -0,0 +1,83 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + const char data1[] = "Drei Phantasien nach Friedrich Holderlin"; + const string str1(data1); + istringstream iss1(str1); + in_iterator_type beg1(iss1); + in_iterator_type end1, it1; + + it1 = find(beg1, beg1, 'l'); + VERIFY( it1 == beg1 ); + VERIFY( *it1 == 'D' ); + + it1 = find(end1, end1, 'D'); + VERIFY( it1 == end1 ); + + it1 = find(end1, end1, 'Z'); + VERIFY( it1 == end1 ); + + it1 = find(beg1, end1, 'P'); + VERIFY( *it1 == 'P' ); + it1 = find(beg1, end1, 't'); + VERIFY( *it1 == 't' ); + ++it1; + VERIFY( *it1 == 'a' ); + + it1 = find(beg1, end1, 'H'); + VERIFY( *it1 == 'H' ); + it1 = find(beg1, end1, 'l'); + VERIFY( *it1 == 'l' ); + ++it1; + it1 = find(beg1, end1, 'l'); + VERIFY( *it1 == 'l' ); + ++it1; + VERIFY( *it1 == 'i' ); + it1 = find(beg1, end1, 'Z'); + VERIFY( it1 == end1 ); + + it1 = find(beg1, end1, 'D'); + VERIFY( it1 == end1 ); + + iss1.seekg(0); + it1 = find(beg1, end1, 'D'); + VERIFY( it1 != end1 ); + VERIFY( *it1 == 'D' ); + ++it1; + VERIFY( *it1 == 'r' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc new file mode 100644 index 000000000..1a4b339d7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc @@ -0,0 +1,61 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// { dg-require-fileio "" } + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + ifstream fbuf("istream_unformatted-1.txt"); + + in_iterator_type beg(fbuf); + in_iterator_type end; + + unsigned found = 0; + for (;;) + { + beg = find(beg, end, '1'); + if (beg == end) + break; + + ++found; + VERIFY( *beg == '1' ); + + for (unsigned sk = 0; sk < 9; sk++) + ++beg; + VERIFY( *beg == '0' ); + } + VERIFY( found == 1500 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc new file mode 100644 index 000000000..8dc5742b3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/1.cc @@ -0,0 +1,83 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + const wchar_t data1[] = L"Drei Phantasien nach Friedrich Holderlin"; + const wstring str1(data1); + wistringstream iss1(str1); + in_iterator_type beg1(iss1); + in_iterator_type end1, it1; + + it1 = find(beg1, beg1, L'l'); + VERIFY( it1 == beg1 ); + VERIFY( *it1 == L'D' ); + + it1 = find(end1, end1, L'D'); + VERIFY( it1 == end1 ); + + it1 = find(end1, end1, L'Z'); + VERIFY( it1 == end1 ); + + it1 = find(beg1, end1, L'P'); + VERIFY( *it1 == L'P' ); + it1 = find(beg1, end1, L't'); + VERIFY( *it1 == L't' ); + ++it1; + VERIFY( *it1 == L'a' ); + + it1 = find(beg1, end1, L'H'); + VERIFY( *it1 == L'H' ); + it1 = find(beg1, end1, L'l'); + VERIFY( *it1 == L'l' ); + ++it1; + it1 = find(beg1, end1, L'l'); + VERIFY( *it1 == L'l' ); + ++it1; + VERIFY( *it1 == L'i' ); + it1 = find(beg1, end1, L'Z'); + VERIFY( it1 == end1 ); + + it1 = find(beg1, end1, L'D'); + VERIFY( it1 == end1 ); + + iss1.seekg(0); + it1 = find(beg1, end1, L'D'); + VERIFY( it1 != end1 ); + VERIFY( *it1 == L'D' ); + ++it1; + VERIFY( *it1 == L'r' ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc new file mode 100644 index 000000000..9251d6117 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc @@ -0,0 +1,59 @@ +// 2006-03-20 Paolo Carlini + +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +// In the occasion of libstdc++/25482 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef istreambuf_iterator in_iterator_type; + + wifstream fbuf("istream_unformatted-1.txt"); + + in_iterator_type beg(fbuf); + in_iterator_type end; + + unsigned found = 0; + for (;;) + { + beg = find(beg, end, L'1'); + if (beg == end) + break; + + ++found; + VERIFY( *beg == L'1' ); + + for (unsigned sk = 0; sk < 9; sk++) + ++beg; + VERIFY( *beg == L'0' ); + } + VERIFY( found == 1500 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..095e811d1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type find(iterator_type, iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..705ad0057 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type find(iterator_type, iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc new file mode 100644 index 000000000..ae1ee462a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.3 [lib.alg.find.end] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; + +using std::find_end; + +void +test1() +{ + int array[] = {0}; + Container con1(array, array); + Container con2(array, array + 1); + VERIFY(find_end(con1.begin(), con1.end(), con1.begin(), con1.end()).ptr == array); + VERIFY(find_end(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array); + VERIFY(find_end(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array + 1); +} + +void +test2() +{ + int array1[] = {2, 2, 1, 2, 2, 1}; + int array2[] = {2, 2}; + Container con1(array1, array1 + 6); + Container con2(array2, array2 + 2); + VERIFY(find_end(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1 + 3); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc new file mode 100644 index 000000000..21c722257 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.3 [lib.alg.find.end] + +// { dg-do compile } + + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct X1 { }; + +struct X2 { }; + +bool predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& lhs1, + forward_iterator_wrapper& rhs1) +{ + return std::find_end(lhs1, lhs1, rhs1, rhs1); +} + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x1, + forward_iterator_wrapper& x2) +{ + return std::find_end(x1, x1, x2, x2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..9e7bc9c4e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type find_end(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type find_end(iterator_type, iterator_type, + iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..c8bae11bd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type find_end(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type find_end(iterator_type, iterator_type, + iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc new file mode 100644 index 000000000..0a3b4a108 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.4 [lib.alg.find.first.of] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; + +using std::find_first_of; + +void +test1() +{ + int array[] = {0}; + Container con1(array, array); + Container con2(array, array + 1); + VERIFY(find_first_of(con1.begin(), con1.end(), con1.begin(), con1.end()).ptr == array); + VERIFY(find_first_of(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array); + VERIFY(find_first_of(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array + 1); +} + +void +test2() +{ + int array1[] = {1 ,2, 3, 4, 5, 6}; + int array2[] = {3, 4, 9}; + Container con1(array1, array1 + 6); + Container con2(array2, array2 + 3); + VERIFY(find_first_of(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1 + 2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc new file mode 100644 index 000000000..60d0ef249 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.4 [lib.alg.find.first.of] + +// { dg-do compile } + + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct X1 { }; + +struct X2 { }; + +bool predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& lhs1, + forward_iterator_wrapper& rhs1) +{ return std::find_first_of(lhs1, lhs1, rhs1, rhs1); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x1, + forward_iterator_wrapper& x2) +{ return std::find_first_of(x1, x1, x2, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/concept_check_1.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/concept_check_1.cc new file mode 100644 index 000000000..c575332b0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/concept_check_1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2004, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-D_GLIBCXX_CONCEPT_CHECKS" } + +#include + +class class1 +{ }; + +class class2 +{ }; + +bool +comp(class1&, class2&) +{ return true; } + +class1 a; +class2 b; + +// http://gcc.gnu.org/ml/libstdc++/2004-10/msg00448.html +void test01() +{ + std::find_first_of(&a, &a, &b, &b, comp); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..7647459d8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type find_first_of(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type find_first_of(iterator_type, iterator_type, + iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..064bff3e1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type find_first_of(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type find_first_of(iterator_type, iterator_type, + iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc new file mode 100644 index 000000000..18aa5edb0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.2 find_if + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::find_if(con.begin(), con.end(), + predicate).ptr == array ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::find_if(con.begin(), con.end(), + predicate).ptr == array + 1 ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( std::find_if(con.begin(), con.end(), + predicate).ptr == array + 3 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc new file mode 100644 index 000000000..0ddbbe4f1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.2 find_if + +// { dg-do compile } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +input_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::find_if(begin, end, pred_function); } + +input_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::find_if(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..6a73e946d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type find_if(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..c4e8f9018 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type find_if(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc new file mode 100644 index 000000000..f8c9b8b89 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/1.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 0; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::find_if_not(con.begin(), con.end(), + predicate).ptr == array ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::find_if_not(con.begin(), con.end(), + predicate).ptr == array + 1 ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( std::find_if_not(con.begin(), con.end(), + predicate).ptr == array + 3 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc new file mode 100644 index 000000000..9f8eba8b8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/check_type.cc @@ -0,0 +1,49 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +input_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::find_if_not(begin, end, pred_function); } + +input_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::find_if_not(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..b8e78c168 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type find_if_not(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2eab0c6df --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if_not/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type find_if_not(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/for_each/1.cc b/libstdc++-v3/testsuite/25_algorithms/for_each/1.cc new file mode 100644 index 000000000..4cfd3e89f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/for_each/1.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-02-19 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include + +struct Function +{ + Function() : tot(0) { } + Function(Function&& f) : tot(f.tot) { f.tot = 0; } + + Function(const Function&) = delete; + + void operator()(int num) + { tot += num; } + + int get() { return tot; } + +private: + int tot; +}; + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::test_container; + using __gnu_test::input_iterator_wrapper; + + typedef test_container Container; + + int array[5] = { 1, 2, 3, 4, 5 }; + Container con(array, array + 5); + + Function f; + Function f_res = std::for_each(con.begin(), con.end(), std::move(f)); + + VERIFY( f_res.get() == 15 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..292d13d9e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function function_type; + + template function_type for_each(iterator_type, iterator_type, + function_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..80667d2d4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/for_each/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function function_type; + + template function_type for_each(iterator_type, iterator_type, + function_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..975c25a96 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + using __gnu_test::void_function; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef void_function generator_type; + + template void generate(iterator_type, iterator_type, generator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..d6433e6e7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + using __gnu_test::void_function; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef void_function generator_type; + + template void generate(iterator_type, iterator_type, generator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/generate_n/25306.cc b/libstdc++-v3/testsuite/25_algorithms/generate_n/25306.cc new file mode 100644 index 000000000..f73ff3d77 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate_n/25306.cc @@ -0,0 +1,30 @@ +// { dg-do compile } + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +struct Size +{ + operator int() { return 0; } +private: + void operator=(Size&); +}; + +// libstdc++/25306 +template int* std::generate_n(int*, Size, int (*)()); diff --git a/libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..fdecf8958 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + using __gnu_test::void_function; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + typedef void_function generator_type; + + template iterator_type generate_n(iterator_type, size_type, generator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..585024699 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/generate_n/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + using __gnu_test::void_function; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef unsigned short size_type; + typedef void_function generator_type; + + template iterator_type generate_n(iterator_type, size_type, generator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/algorithm_parallel_mode.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/algorithm_parallel_mode.cc new file mode 100644 index 000000000..7edbd8855 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/algorithm_parallel_mode.cc @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-D_GLIBCXX_PARALLEL -fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm.cc new file mode 100644 index 000000000..1286f8719 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm.cc @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed1.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed1.cc new file mode 100644 index 000000000..ab0d0ac36 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed1.cc @@ -0,0 +1,88 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test() +{ + typedef unsigned short value_type; + typedef std::vector vector_type; + + const value_type c(0); + + vector_type v(10), result(20); + + std::equal(v.begin(), v.end(), v.begin()); + std::equal(v.begin(), v.end(), v.begin(), std::equal_to()); + __gnu_parallel::equal(v.begin(), v.end(), v.begin()); + __gnu_parallel::equal(v.begin(), v.end(), v.begin(), + std::equal_to()); + + std::find(v.begin(), v.end(), c); + __gnu_parallel::find(v.begin(), v.end(), c); + + std::find_first_of(v.begin(), v.end(), v.begin(), v.end()); + std::find_first_of(v.begin(), v.end(), v.begin(), v.end(), + std::equal_to()); + __gnu_parallel::find_first_of(v.begin(), v.end(), v.begin(), v.end()); + __gnu_parallel::find_first_of(v.begin(), v.end(), v.begin(), v.end(), + std::equal_to()); + + std::search_n(v.begin(), v.end(), 5, value_type(1)); + std::search_n(v.begin(), v.end(), 5, value_type(1), + std::equal_to()); + __gnu_parallel::search_n(v.begin(), v.end(), 5, value_type(1)); + __gnu_parallel::search_n(v.begin(), v.end(), 5, value_type(1), + std::equal_to()); + + std::merge(v.begin(), v.end(), v.begin(), v.end(), result.begin()); + std::merge(v.begin(), v.end(), v.begin(), v.end(), result.begin(), + std::less()); + __gnu_parallel::merge(v.begin(), v.end(), v.begin(), v.end(), + result.begin()); + __gnu_parallel::merge(v.begin(), v.end(), v.begin(), v.end(), + result.begin(), std::less()); + + std::nth_element(v.begin(), v.begin() + 5, v.end()); + std::nth_element(v.begin(), v.begin() + 5, v.end(), std::less()); + __gnu_parallel::nth_element(v.begin(), v.begin() + 5, v.end()); + __gnu_parallel::nth_element(v.begin(), v.begin() + 5, v.end(), + std::less()); + + std::partial_sort(v.begin(), v.begin() + 5, v.end()); + std::partial_sort(v.begin(), v.begin() + 5, v.end(), + std::less()); + __gnu_parallel::partial_sort(v.begin(), v.begin() + 5, v.end()); + __gnu_parallel::partial_sort(v.begin(), v.begin() + 5, v.end(), + std::less()); + + std::min_element(v.begin(), v.end()); + std::min_element(v.begin(), v.end(), std::less()); + __gnu_parallel::min_element(v.begin(), v.end()); + __gnu_parallel::min_element(v.begin(), v.end(), std::less()); + + std::max_element(v.begin(), v.end()); + std::max_element(v.begin(), v.end(), std::less()); + __gnu_parallel::max_element(v.begin(), v.end()); + __gnu_parallel::max_element(v.begin(), v.end(), std::less()); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed2.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed2.cc new file mode 100644 index 000000000..56f95b6fb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed2.cc @@ -0,0 +1,93 @@ +// { dg-do compile } +// { dg-require-parallel-mode "" } +// { dg-options "-fopenmp" { target *-*-* } } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// Make sure to test without _GLIBCXX_PARALLEL +#ifdef _GLIBCXX_PARALLEL +# undef _GLIBCXX_PARALLEL +#endif + +#include +#include +#include + +void test() +{ + typedef unsigned short value_type; + typedef std::vector vector_type; + + const value_type c(0); + + vector_type v(10), result(20); + + std::equal(v.begin(), v.end(), v.begin()); + std::equal(v.begin(), v.end(), v.begin(), std::equal_to()); + __gnu_parallel::equal(v.begin(), v.end(), v.begin()); + __gnu_parallel::equal(v.begin(), v.end(), v.begin(), + std::equal_to()); + + std::find(v.begin(), v.end(), c); + __gnu_parallel::find(v.begin(), v.end(), c); + + std::find_first_of(v.begin(), v.end(), v.begin(), v.end()); + std::find_first_of(v.begin(), v.end(), v.begin(), v.end(), + std::equal_to()); + __gnu_parallel::find_first_of(v.begin(), v.end(), v.begin(), v.end()); + __gnu_parallel::find_first_of(v.begin(), v.end(), v.begin(), v.end(), + std::equal_to()); + + std::search_n(v.begin(), v.end(), 5, value_type(1)); + std::search_n(v.begin(), v.end(), 5, value_type(1), + std::equal_to()); + __gnu_parallel::search_n(v.begin(), v.end(), 5, value_type(1)); + __gnu_parallel::search_n(v.begin(), v.end(), 5, value_type(1), + std::equal_to()); + + std::merge(v.begin(), v.end(), v.begin(), v.end(), result.begin()); + std::merge(v.begin(), v.end(), v.begin(), v.end(), result.begin(), + std::less()); + __gnu_parallel::merge(v.begin(), v.end(), v.begin(), v.end(), + result.begin()); + __gnu_parallel::merge(v.begin(), v.end(), v.begin(), v.end(), + result.begin(), std::less()); + + std::nth_element(v.begin(), v.begin() + 5, v.end()); + std::nth_element(v.begin(), v.begin() + 5, v.end(), std::less()); + __gnu_parallel::nth_element(v.begin(), v.begin() + 5, v.end()); + __gnu_parallel::nth_element(v.begin(), v.begin() + 5, v.end(), + std::less()); + + std::partial_sort(v.begin(), v.begin() + 5, v.end()); + std::partial_sort(v.begin(), v.begin() + 5, v.end(), + std::less()); + __gnu_parallel::partial_sort(v.begin(), v.begin() + 5, v.end()); + __gnu_parallel::partial_sort(v.begin(), v.begin() + 5, v.end(), + std::less()); + + std::min_element(v.begin(), v.end()); + std::min_element(v.begin(), v.end(), std::less()); + __gnu_parallel::min_element(v.begin(), v.end()); + __gnu_parallel::min_element(v.begin(), v.end(), std::less()); + + std::max_element(v.begin(), v.end()); + std::max_element(v.begin(), v.end(), std::less()); + __gnu_parallel::max_element(v.begin(), v.end()); + __gnu_parallel::max_element(v.begin(), v.end(), std::less()); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc new file mode 100644 index 000000000..a78da2ecb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/headers/algorithm/synopsis.cc @@ -0,0 +1,583 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace std + { + // 25.1, non-modifying sequence operations: + template + _Funct + for_each(_IIter, _IIter, _Funct); + + template + _IIter + find(_IIter, _IIter, const _Tp&); + + template + _IIter + find_if(_IIter, _IIter, _Predicate); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + bool + all_of(_IIter, _IIter, _Predicate); + + template + bool + any_of(_IIter, _IIter, _Predicate); + + template + bool + none_of(_IIter, _IIter, _Predicate); + + template + _IIter + find_if_not(_IIter, _IIter, _Predicate); + + template + bool + is_partitioned(_IIter, _IIter, _Predicate); + + template + _FIter + partition_point(_FIter, _FIter, _Predicate); +#endif + + template + _FIter1 + find_end(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _FIter1 + find_end(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _FIter1 + find_first_of(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _FIter1 + find_first_of(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _FIter + adjacent_find(_FIter, _FIter); + + template + _FIter + adjacent_find(_FIter, _FIter, _BinaryPredicate); + + template + typename iterator_traits<_IIter>::difference_type + count(_IIter, _IIter, const _Tp&); + + template + typename iterator_traits<_IIter>::difference_type + count_if(_IIter, _IIter, _Predicate); + + template + pair<_IIter1, _IIter2> + mismatch(_IIter1, _IIter1, _IIter2); + + template + pair<_IIter1, _IIter2> + mismatch(_IIter1, _IIter1, _IIter2, _BinaryPredicate); + + template + bool + equal(_IIter1, _IIter1, _IIter2); + + template + bool + equal(_IIter1, _IIter1, _IIter2, _BinaryPredicate); + + template + _FIter1 + search(_FIter1, _FIter1, _FIter2, _FIter2); + + template + _FIter1 + search(_FIter1, _FIter1, _FIter2, _FIter2, _BinaryPredicate); + + template + _FIter + search_n(_FIter, _FIter, _Size, const _Tp&); + + template + _FIter + search_n(_FIter, _FIter, _Size, const _Tp&, _BinaryPredicate); + + // 25.2, modifying sequence operations: + // 25.2.1, copy: + template + _OIter + copy(_IIter, _IIter, _OIter); + + template + _BIter2 + copy_backward (_BIter1, _BIter1, _BIter2); + + // 25.2.2, swap: + template + void + swap(_Tp&, _Tp& b); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + void + swap(_Tp (&)[_Nm], _Tp (&)[_Nm]); +#endif + + template + _FIter2 + swap_ranges(_FIter1 first1, _FIter1, _FIter2); + + template + void + iter_swap(_FIter1, _FIter2 b); + + template + _OIter + transform(_IIter, _IIter, _OIter, _UnaryOperation op); + + template + _OIter + transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation); + + template + void + replace(_FIter, _FIter, const _Tp&, const _Tp&); + + template + void + replace_if(_FIter, _FIter, _Predicate, const _Tp&); + + template + _OIter + replace_copy(_IIter, _IIter, _OIter, const _Tp&, const _Tp&); + + template + _OIter + replace_copy_if(_Iter, _Iter, _OIter, _Predicate, const _Tp&); + + template + void + fill(_FIter, _FIter, const _Tp&); + + template + void + fill_n(_OIter, _Size n, const _Tp&); + + template + void + generate(_FIter, _FIter, _Generator); + + template + void + generate_n(_OIter, _Size, _Generator); + + template + _FIter + remove(_FIter, _FIter, const _Tp&); + + template + _FIter + remove_if(_FIter, _FIter, _Predicate); + + template + _OIter + remove_copy(_IIter, _IIter, _OIter, const _Tp&); + + template + _OIter + remove_copy_if(_IIter, _IIter, _OIter, _Predicate); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + _OIter + copy_if(_IIter, _IIter, _OIter, _Predicate); + + template + _OIter + copy_n(_IIter, _Size, _OIter); + + template + pair<_OIter1, _OIter2> + partition_copy(_IIter, _IIter, _OIter1, _OIter2, _Predicate); +#endif + + template + _FIter + unique(_FIter, _FIter); + + template + _FIter + unique(_FIter, _FIter, _BinaryPredicate); + + template + _OIter + unique_copy(_IIter, _IIter, _OIter); + + template + _OIter + unique_copy(_IIter, _IIter, _OIter, _BinaryPredicate); + + template + void + reverse(_BIter, _BIter); + + template + _OIter + reverse_copy(_BIter, _BIter, _OIter); + + template + void + rotate(_FIter, _FIter, _FIter); + + template + _OIter + rotate_copy (_FIter, _FIter, _FIter, _OIter); + + template + void + random_shuffle(_RAIter, _RAIter); + + template + void + random_shuffle(_RAIter, _RAIter, _Generator&); + + // 25.2.12, partitions: + template + _BIter + partition(_BIter, _BIter, _Predicate); + + template + _BIter + stable_partition(_BIter, _BIter, _Predicate); + + // 25.3, sorting and related operations: + // 25.3.1, sorting: + template + void + sort(_RAIter, _RAIter); + + template + void + sort(_RAIter, _RAIter, _Compare); + + template + void + stable_sort(_RAIter, _RAIter); + + template + void + stable_sort(_RAIter, _RAIter, _Compare); + + template + void + partial_sort(_RAIter, _RAIter, _RAIter); + + template + void + partial_sort(_RAIter, _RAIter, _RAIter, _Compare); + + template + _RAIter + partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter); + + template + _RAIter + partial_sort_copy(_IIter, _IIter, _RAIter, _RAIter, _Compare); + + template + void + nth_element(_RAIter, _RAIter, _RAIter); + + template + void + nth_element(_RAIter, _RAIter, _RAIter, _Compare); + + // 25.3.3, binary search: + template + _FIter + lower_bound(_FIter, _FIter, const _Tp&); + + template + _FIter + lower_bound(_FIter, _FIter, const _Tp&, _Compare); + + template + _FIter + upper_bound(_FIter, _FIter, const _Tp&); + + template + _FIter + upper_bound(_FIter, _FIter, const _Tp&, _Compare); + + template + pair<_FIter, _FIter> + equal_range(_FIter, _FIter, const _Tp&); + + template + pair<_FIter, _FIter> + equal_range(_FIter, _FIter, const _Tp&, _Compare); + + template + bool + binary_search(_FIter, _FIter, const _Tp&); + + template + bool + binary_search(_FIter, _FIter, const _Tp&, _Compare); + + // 25.3.4, merge: + template + _OIter + merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _OIter + merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + void + inplace_merge(_BIter, _BIter, _BIter); + + template + void + inplace_merge(_BIter, _BIter, _BIter, _Compare); + + // 25.3.5, set operations: + template + bool + includes(_IIter1, _IIter1, _IIter2, _IIter2); + + template + bool + includes(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); + + template + _OIter + set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _OIter + set_union(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _OIter + set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _OIter + set_intersection(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _OIter + set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _OIter + set_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter, _Compare); + + template + _OIter + set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, _OIter); + + template + _OIter + set_symmetric_difference(_IIter1, _IIter1, _IIter2, _IIter2, + _OIter, _Compare); + + // 25.3.6, heap operations: + template + void + push_heap(_RAIter, _RAIter); + + template + void + push_heap(_RAIter, _RAIter, _Compare); + + template + void + pop_heap(_RAIter, _RAIter); + + template + void + pop_heap(_RAIter, _RAIter, _Compare); + + template + void + make_heap(_RAIter, _RAIter); + + template + void + make_heap(_RAIter, _RAIter, _Compare); + + template + void + sort_heap(_RAIter, _RAIter); + + template + void + sort_heap(_RAIter, _RAIter, _Compare); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + bool + is_heap(_RAIter, _RAIter); + + template + bool + is_heap(_RAIter, _RAIter, _Compare); + + template + _RAIter + is_heap_until(_RAIter, _RAIter); + + template + _RAIter + is_heap_until(_RAIter, _RAIter, _Compare); + + template + bool + is_sorted(_FIter, _FIter); + + template + bool + is_sorted(_FIter, _FIter, _Compare); + + template + _FIter + is_sorted_until(_FIter, _FIter); + + template + _FIter + is_sorted_until(_FIter, _FIter, _Compare); +#endif + + // 25.3.7, minimum and maximum: + template + const _Tp& + min(const _Tp&, const _Tp&); + + template + const _Tp& + min(const _Tp&, const _Tp&, _Compare); + + template + const _Tp& + max(const _Tp&, const _Tp&); + + template + const _Tp& + max(const _Tp&, const _Tp&, _Compare); + + template + _FIter + min_element(_FIter, _FIter); + + template + _FIter + min_element(_FIter, _FIter, _Compare); + + template + _FIter + max_element(_FIter, _FIter); + + template + _FIter + max_element(_FIter, _FIter, _Compare); + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template + pair + minmax(const _Tp&, const _Tp&); + + template + pair + minmax(const _Tp&, const _Tp&, _Compare); + + template + pair<_FIter, _FIter> + minmax_element(_FIter, _FIter); + + template + pair<_FIter, _FIter> + minmax_element(_FIter, _FIter, _Compare); + + template + _Tp + min(initializer_list<_Tp>); + + template + _Tp + min(initializer_list<_Tp>, _Compare); + + template + _Tp + max(initializer_list<_Tp>); + + template + _Tp + max(initializer_list<_Tp>, _Compare); + + template + pair<_Tp, _Tp> + minmax(initializer_list<_Tp>); + + template + pair<_Tp, _Tp> + minmax(initializer_list<_Tp>, _Compare); +#endif + + template + bool + lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2); + + template + bool + lexicographical_compare(_IIter1, _IIter1, _IIter2, _IIter2, _Compare); + + // 25.3.9, permutations + template + bool + next_permutation(_BIter, _BIter); + + template + bool + next_permutation(_BIter, _BIter, _Compare); + + template + bool + prev_permutation(_BIter, _BIter); + + template + bool + prev_permutation(_BIter, _BIter, _Compare); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/headers/cstdlib/functions_std.cc b/libstdc++-v3/testsuite/25_algorithms/headers/cstdlib/functions_std.cc new file mode 100644 index 000000000..34908e893 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/headers/cstdlib/functions_std.cc @@ -0,0 +1,26 @@ +// { dg-do compile } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +namespace gnu +{ + using std::bsearch; + using std::qsort; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/heap/1.cc b/libstdc++-v3/testsuite/25_algorithms/heap/1.cc new file mode 100644 index 000000000..1683a83f7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/heap/1.cc @@ -0,0 +1,145 @@ +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include +#include + +const int A[] = {1, 11, 12, 3, 10, 6, 17, 4, 8, 2, 5, 13, 9, 15, 14, 16, 7}; +const int B[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int C[] = {17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); + +// This functor has the equivalent functionality of std::greater<>, +// but there is no dependency on and it also tracks the +// number of invocations since creation. +class Gt +{ +public: + static int count() { return _M_count; } + static void reset() { _M_count = 0; } + + bool + operator()(const int& x, const int& y) + { + ++_M_count; + return x > y; + } + +private: + static int _M_count; +}; + +int Gt::_M_count = 0; + +// Exercise all of the heap functions for operator<. The intermediate +// results between push_heap and pop_heap and make_heap and sort_heap +// are not checked (they could be). +void +test01() +{ + bool test __attribute__((unused)) = true; + + // sort array s1 using push_heap/pop_heap + int s1[N]; + std::copy(A, A + N, s1); + VERIFY(std::equal(s1, s1 + N, A)); + + for (int i = 2; i <= N; ++i) + std::push_heap(s1, s1 + i); + + for (int i = N; i >= 2; --i) + std::pop_heap(s1, s1 + i); + + VERIFY(std::equal(s1, s1 + N, B)); + + // sort array s2 using make_heap/sort_heap + int s2[N]; + std::copy(A, A + N, s2); + VERIFY(std::equal(s2, s2 + N, A)); + + std::make_heap(s2, s2 + N); + std::sort_heap(s2, s2 + N); + VERIFY(std::equal(s2, s2 + N, B)); +} + +// Perform same tests as above but with the comparison predicate +// versions, and add complexity constraint checks. +void +test02() +{ + bool test __attribute__((unused)) = true; + + Gt gt; + +#ifndef _GLIBCXX_DEBUG + //const int logN = static_cast(std::log(static_cast(N)) + 0.5); + const int logN = 3; +#endif + + int s1[N]; + std::copy(A, A + N, s1); + VERIFY(std::equal(s1, s1 + N, A)); + + for (int i = 2; i <= N; ++i) + { + std::push_heap(s1, s1 + i, gt); +#ifndef _GLIBCXX_DEBUG + VERIFY(gt.count() <= logN); +#endif + gt.reset(); + } + + for (int i = N; i >= 2; --i) + { + std::pop_heap(s1, s1 + i, gt); +#ifndef _GLIBCXX_DEBUG + VERIFY(gt.count() <= 2 * logN); +#endif + gt.reset(); + } + + VERIFY(std::equal(s1, s1 + N, C)); + + // sort array s2 using make_heap/sort_heap + int s2[N]; + std::copy(A, A + N, s2); + VERIFY(std::equal(s2, s2 + N, A)); + + std::make_heap(s2, s2 + N, gt); +#ifndef _GLIBCXX_DEBUG + VERIFY(gt.count() <= 3 * N); +#endif + gt.reset(); + + std::sort_heap(s2, s2 + N, gt); +#ifndef _GLIBCXX_DEBUG + VERIFY(gt.count() <= N * logN); +#endif + + VERIFY(std::equal(s2, s2 + N, C)); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/heap/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/heap/moveable.cc new file mode 100644 index 000000000..a744c001f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/heap/moveable.cc @@ -0,0 +1,156 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++0x -DITERATIONS=5" { target simulator } } + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +#ifndef ITERATIONS +#define ITERATIONS 9 +#endif + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container container; +typedef test_container container_ref; + +void +check_make(int* array, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct makeheap[9]; + int makeheap_ref[9]; + std::copy(array, array + length, makeheap); + std::copy(array, array + length, makeheap_ref); + container makecon(makeheap, makeheap + length); + container_ref makecon_ref(makeheap_ref, makeheap_ref + length); + std::make_heap(makecon.begin(), makecon.end()); + std::make_heap(makecon_ref.begin(), makecon_ref.end()); + for (int z = 0; z < length; ++z) + VERIFY( makeheap[z] == makeheap_ref[z] ); + VERIFY( std::__is_heap(makecon.begin(), makecon.end()) ); + for (int z = 0; z < length; ++z) + VERIFY( makeheap[z].valid ); +} + +void +check_pop(int* array, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct popheap[9]; + int popheap_ref[9]; + std::copy(array, array + length, popheap); + std::copy(array, array + length, popheap_ref); + container popcon(popheap, popheap + length); + container_ref popcon_ref(popheap_ref, popheap_ref + length); + std::pop_heap(popcon.begin(), popcon.end()); + std::pop_heap(popcon_ref.begin(), popcon_ref.end()); + for (int z = 0; z < length; ++z) + VERIFY( popheap[z] == popheap_ref[z] ); + VERIFY( (std::__is_heap(popheap, popheap + length - 1)) ); + for (int z = 0; z < length; ++z) + VERIFY( popheap[z].val <= popheap[length-1].val && popheap[z].valid ); +} + +void +check_sort(int* array, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct sortheap[9]; + int sortheap_ref[9]; + std::copy(array, array + length, sortheap); + std::copy(array, array + length, sortheap_ref); + container sortcon(sortheap, sortheap + length); + container_ref sortcon_ref(sortheap_ref, sortheap_ref + length); + std::sort_heap(sortcon.begin(), sortcon.end()); + std::sort_heap(sortcon_ref.begin(), sortcon_ref.end()); + for (int z = 0; z < length; ++z) + VERIFY( sortheap[z] == sortheap_ref[z] ); + for (int z = 0; z < length - 1; ++z) + VERIFY( sortheap[z].val <= sortheap[z + 1].val && sortheap[z].valid ); + VERIFY( sortheap[length - 1].valid ); +} + +void +check_push(int* array, int pushval, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct pushheap[10]; + int pushheap_ref[10]; + std::copy(array, array + length, pushheap); + std::copy(array, array + length, pushheap_ref); + pushheap[length] = pushval; + pushheap_ref[length] = pushval; + container pushcon(pushheap, pushheap + length + 1); + container_ref pushcon_ref(pushheap_ref, pushheap_ref + length + 1); + std::push_heap(pushcon.begin(), pushcon.end()); + std::push_heap(pushcon_ref.begin(), pushcon_ref.end()); + for (int z = 0; z < length + 1; ++z) + VERIFY( pushheap[z] == pushheap_ref[z] ); + VERIFY( std::__is_heap(pushheap, pushheap + length + 1) ); + for (int z = 0; z < length + 1; ++z) + VERIFY( pushheap[z].valid ); +} + +void +test01() +{ + int array[9]; + for (int i = 1; i < ITERATIONS; ++i) + { + for(int z = 0; z < i; ++z) + array[z] = z; + while (std::next_permutation(array, array + i)) + { + check_make(array, i); + if (std::__is_heap(array, array + i)) + { + check_pop(array, i); + check_sort(array, i); + for (int pushval = -1; pushval <= i; ++pushval) + check_push(array, pushval, i); + } + } + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc new file mode 100644 index 000000000..562ab466a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc @@ -0,0 +1,157 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++0x -DITERATIONS=5" { target simulator } } + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include + +#ifndef ITERATIONS +#define ITERATIONS 9 +#endif + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container container; +typedef test_container container_ref; + +bool are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +bool are_ordered_int(const int& lhs, const int& rhs) +{ return lhs < rhs; } + +void +check_make(int* array, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct makeheap[9]; + int makeheap_ref[9]; + std::copy(array, array + length, makeheap); + std::copy(array, array + length, makeheap_ref); + container makecon(makeheap, makeheap + length); + container_ref makecon_ref(makeheap_ref, makeheap_ref + length); + std::make_heap(makecon.begin(), makecon.end(), are_ordered); + std::make_heap(makecon_ref.begin(), makecon_ref.end(), are_ordered_int); + for (int z = 0; z < length; ++z) + VERIFY( makeheap[z] == makeheap_ref[z] ); + VERIFY( std::__is_heap(makecon.begin(), makecon.end(), are_ordered) ); + for (int z = 0; z < length; ++z) + VERIFY( makeheap[z].valid ); +} + +void +check_pop(int* array, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct popheap[9]; + int popheap_ref[9]; + std::copy(array, array + length, popheap); + std::copy(array, array + length, popheap_ref); + container popcon(popheap, popheap + length); + container_ref popcon_ref(popheap_ref, popheap_ref + length); + std::pop_heap(popcon.begin(), popcon.end(), are_ordered); + std::pop_heap(popcon_ref.begin(), popcon_ref.end(), are_ordered_int); + for (int z = 0; z < length; ++z) + VERIFY( popheap[z] == popheap_ref[z] ); + VERIFY( (std::__is_heap(popheap, popheap + length - 1), are_ordered) ); + for (int z = 0; z < length; ++z) + VERIFY( popheap[z].val <= popheap[length-1].val && popheap[z].valid ); +} + +void +check_sort(int* array, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct sortheap[9]; + int sortheap_ref[9]; + std::copy(array, array + length, sortheap); + std::copy(array, array + length, sortheap_ref); + container sortcon(sortheap, sortheap + length); + container_ref sortcon_ref(sortheap_ref, sortheap_ref + length); + std::sort_heap(sortcon.begin(), sortcon.end(), are_ordered); + std::sort_heap(sortcon_ref.begin(), sortcon_ref.end(), are_ordered_int); + for (int z = 0; z < length; ++z) + VERIFY( sortheap[z] == sortheap_ref[z] ); + for (int z = 0; z < length - 1; ++z) + VERIFY( sortheap[z].val <= sortheap[z + 1].val && sortheap[z].valid ); + VERIFY( sortheap[length - 1].valid ); +} + +void +check_push(int* array, int pushval, int length) +{ + bool test __attribute__((unused)) = true; + + rvalstruct pushheap[10]; + int pushheap_ref[10]; + std::copy(array, array + length, pushheap); + std::copy(array, array + length, pushheap_ref); + pushheap[length] = pushval; + pushheap_ref[length] = pushval; + container pushcon(pushheap, pushheap + length + 1); + container_ref pushcon_ref(pushheap_ref, pushheap_ref + length + 1); + std::push_heap(pushcon.begin(), pushcon.end(), are_ordered); + std::push_heap(pushcon_ref.begin(), pushcon_ref.end(), are_ordered_int); + for (int z = 0; z < length + 1; ++z) + VERIFY( pushheap[z] == pushheap_ref[z] ); + VERIFY( std::__is_heap(pushheap, pushheap + length + 1) ); + for (int z = 0; z < length + 1; ++z) + VERIFY( pushheap[z].valid ); +} + +void +test01() +{ + int array[9]; + for (int i = 1; i < ITERATIONS; ++i) + { + for(int z = 0; z < i; ++z) + array[z] = z; + while (std::next_permutation(array, array + i)) + { + check_make(array, i); + if (std::__is_heap(array, array + i, are_ordered_int)) + { + check_pop(array, i); + check_sort(array, i); + for (int pushval = -1; pushval <= i; ++pushval) + check_push(array, pushval, i); + } + } + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/1.cc b/libstdc++-v3/testsuite/25_algorithms/includes/1.cc new file mode 100644 index 000000000..441bdae05 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.1 [lib.includes] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using std::includes; + +typedef test_container Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array[] = {0}; + Container con1(array, array); + Container con2(array, array); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 1}; + Container con1(array, array); + Container con2(array, array + 2); + VERIFY(!includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 1}; + Container con1(array, array + 2); + Container con2(array, array); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1, 2, 3, 4, 6, 8, 9}; + int array2[] = {2, 4, 6, 8}; + Container con1(array1, array1 + 7); + Container con2(array2, array2 + 4); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1, 2, 3, 5}; + int array2[] = {2, 4, 6, 8}; + Container con1(array1, array1 + 4); + Container con2(array2, array2 + 4); + VERIFY(!includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc new file mode 100644 index 000000000..36740a624 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.1 [lib.includes] + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) +{ return true; } + +struct X { }; + +bool +predicate(const X&, const X&) +{ return true; } + +bool +test1(input_iterator_wrapper& s) +{ return std::includes(s, s, s, s); } + +bool +test2(input_iterator_wrapper& x) +{ return std::includes(x, x, x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..7c0cc6d6b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool includes(iterator_type, iterator_type, iterator_type, + iterator_type); + + template bool includes(iterator_type, iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..3180848fb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool includes(iterator_type, iterator_type, iterator_type, + iterator_type); + + template bool includes(iterator_type, iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc new file mode 100644 index 000000000..d4da753b6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.4 [lib.alg.merge] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::inplace_merge; + +typedef test_container container; + +void +test1() +{ + int array[] = { 1 }; + container con1(array, array); + inplace_merge(con1.begin(), con1.end(), con1.end()); + container con2(array, array + 1); + inplace_merge(con2.begin(), con2.end(), con2.end()); + inplace_merge(con2.begin(), con2.begin(), con2.end()); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + int array[] = { 0, 2, 4, 1, 3, 5 }; + container con(array, array + 6); + inplace_merge(con.begin(), con.it(3), con.end()); + VERIFY( array[0] == 0 && array[1] == 1 && array[2] == 2 + && array[3] == 3 && array[4] == 4 && array[5] == 5 ); +} + +struct S +{ + int a; + int b; + S(int _a, int _b) : a(_a), b(_b) { } + S() { } + bool + operator<(const S& _s) const + { return a < _s.a; } +}; + +void +test3() +{ + bool test __attribute__((unused)) = true; + + S s[4]; + s[0].a = 0; + s[1].a = 1; + s[2].a = 0; + s[3].a = 1; + s[0].b = 0; + s[1].b = 0; + s[2].b = 1; + s[3].b = 1; + inplace_merge(s, s + 2, s + 4); + VERIFY( s[0].b == 0 && s[1].b == 1 && s[2].b == 0 && s[3].b == 1 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/49559.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/49559.cc new file mode 100644 index 000000000..8b7b52e3f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/49559.cc @@ -0,0 +1,72 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +const int A[] = { 0, 1, 2, 3, 4, 5 }; +const int N = 6; + +bool are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +// libstdc++/49559 +void test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[6]; + std::copy(A, A + N, s1); + Container con1(s1, s1 + N); + std::inplace_merge(con1.begin(), con1.it(4), con1.end()); + VERIFY( s1[0] == 0 && s1[1] == 1 && s1[2] == 2 + && s1[3] == 3 && s1[4] == 4 && s1[5] == 5 ); + VERIFY( s1[0].valid && s1[1].valid && s1[2].valid + && s1[3].valid && s1[4].valid && s1[5].valid ); + + rvalstruct s2[6]; + std::copy(A, A + N, s2); + Container con2(s2, s2 + N); + std::inplace_merge(con2.begin(), con2.it(4), con2.end(), are_ordered); + VERIFY( s2[0] == 0 && s2[1] == 1 && s2[2] == 2 + && s2[3] == 3 && s2[4] == 4 && s2[5] == 5 ); + VERIFY( s2[0].valid && s2[1].valid && s2[2].valid + && s2[3].valid && s2[4].valid && s2[5].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc new file mode 100644 index 000000000..d4526a80a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.4 [lib.alg.merge] + +// { dg-do compile } + +#include +#include + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(bidirectional_iterator_wrapper& s) +{ + std::inplace_merge(s, s, s); +} + +void +test2(bidirectional_iterator_wrapper& x) +{ + std::inplace_merge(x, x, x, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc new file mode 100644 index 000000000..6509957da --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.4 [lib.alg.merge] + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int array1[]={0,2,4,1,3,5}; + rvalstruct rv_array1[6]; + std::copy(array1, array1 + 6, rv_array1); + container con1(rv_array1, rv_array1 + 6); + std::inplace_merge(con1.begin(), con1.it(3), con1.end()); + VERIFY( rv_array1[0] == 0 && rv_array1[1] == 1 && rv_array1[2] == 2 + && rv_array1[3] == 3 && rv_array1[4] == 4 && rv_array1[5] == 5 ); + + int array2[]={0,2,4,5,1,3}; + rvalstruct rv_array2[6]; + std::copy(array2, array2 + 6, rv_array2); + container con2(rv_array2, rv_array2 + 6); + std::inplace_merge(con2.begin(), con2.it(4), con2.end()); + VERIFY( rv_array2[0] == 0 && rv_array2[1] == 1 && rv_array2[2] == 2 + && rv_array2[3] == 3 && rv_array2[4] == 4 && rv_array2[5] == 5 ); + + int array3[]={1,1,1,2,2,2}; + rvalstruct rv_array3[6]; + std::copy(array3, array3 + 6, rv_array3); + container con3(rv_array3, rv_array3 + 6); + std::inplace_merge(con3.begin(), con3.it(3), con3.end()); + VERIFY( rv_array3[0] == 1 && rv_array3[1] == 1 && rv_array3[2] == 1 + && rv_array3[3] == 2 && rv_array3[4] == 2 && rv_array3[5] == 2 ); + + int array4[]={1,1,1,1,2,2}; + rvalstruct rv_array4[6]; + std::copy(array4, array4 + 6, rv_array4); + container con4(rv_array4, rv_array4 + 6); + std::inplace_merge(con4.begin(), con4.it(4), con4.end()); + VERIFY( rv_array4[0] == 1 && rv_array4[1] == 1 && rv_array4[2] == 1 + && rv_array4[3] == 1 && rv_array4[4] == 2 && rv_array4[5] == 2 ); + + int array5[]={3,3,3,3}; + rvalstruct rv_array5[4]; + std::copy(array5, array5 + 4, rv_array5); + container con5(rv_array5, rv_array5 + 4); + std::inplace_merge(con5.begin(), con5.it(2), con5.end()); + VERIFY( rv_array5[0] == 3 && rv_array5[1] == 3 && rv_array5[2] == 3 + && rv_array5[3] == 3 ); + + int array6[]={3,3,3}; + rvalstruct rv_array6[3]; + std::copy(array6, array6 + 3, rv_array6); + container con6(rv_array6, rv_array6 + 3); + std::inplace_merge(con6.begin(), con6.it(0), con6.end()); + VERIFY( rv_array6[0] == 3 && rv_array6[1] == 3 && rv_array6[2] == 3 ); + + int array7[]={3,3}; + rvalstruct rv_array7[2]; + std::copy(array7, array7 + 2, rv_array7); + container con7(rv_array7, rv_array7 + 2); + std::inplace_merge(con7.begin(), con7.it(2), con7.end()); + VERIFY( rv_array7[0] == 3 && rv_array7[1] == 3 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc new file mode 100644 index 000000000..a3a898cd5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/moveable2.cc @@ -0,0 +1,102 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.4 [lib.alg.merge] + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container container; + +bool +are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test01() +{ + bool test __attribute__((unused)) = true; + + int array1[]={0,2,4,1,3,5}; + rvalstruct rv_array1[6]; + std::copy(array1, array1 + 6, rv_array1); + container con1(rv_array1, rv_array1 + 6); + std::inplace_merge(con1.begin(), con1.it(3), con1.end(), are_ordered); + VERIFY( rv_array1[0] == 0 && rv_array1[1] == 1 && rv_array1[2] == 2 + && rv_array1[3] == 3 && rv_array1[4] == 4 && rv_array1[5] == 5 ); + + int array2[]={0,2,4,5,1,3}; + rvalstruct rv_array2[6]; + std::copy(array2, array2 + 6, rv_array2); + container con2(rv_array2, rv_array2 + 6); + std::inplace_merge(con2.begin(), con2.it(4), con2.end(), are_ordered); + VERIFY( rv_array2[0] == 0 && rv_array2[1] == 1 && rv_array2[2] == 2 + && rv_array2[3] == 3 && rv_array2[4] == 4 && rv_array2[5] == 5 ); + + int array3[]={1,1,1,2,2,2}; + rvalstruct rv_array3[6]; + std::copy(array3, array3 + 6, rv_array3); + container con3(rv_array3, rv_array3 + 6); + std::inplace_merge(con3.begin(), con3.it(3), con3.end(), are_ordered); + VERIFY( rv_array3[0] == 1 && rv_array3[1] == 1 && rv_array3[2] == 1 + && rv_array3[3] == 2 && rv_array3[4] == 2 && rv_array3[5] == 2 ); + + int array4[]={1,1,1,1,2,2}; + rvalstruct rv_array4[6]; + std::copy(array4, array4 + 6, rv_array4); + container con4(rv_array4, rv_array4 + 6); + std::inplace_merge(con4.begin(), con4.it(4), con4.end(), are_ordered); + VERIFY( rv_array4[0] == 1 && rv_array4[1] == 1 && rv_array4[2] == 1 + && rv_array4[3] == 1 && rv_array4[4] == 2 && rv_array4[5] == 2 ); + + int array5[]={3,3,3,3}; + rvalstruct rv_array5[4]; + std::copy(array5, array5 + 4, rv_array5); + container con5(rv_array5, rv_array5 + 4); + std::inplace_merge(con5.begin(), con5.it(2), con5.end(), are_ordered); + VERIFY( rv_array5[0] == 3 && rv_array5[1] == 3 && rv_array5[2] == 3 + && rv_array5[3] == 3 ); + + int array6[]={3,3,3}; + rvalstruct rv_array6[3]; + std::copy(array6, array6 + 3, rv_array6); + container con6(rv_array6, rv_array6 + 3); + std::inplace_merge(con6.begin(), con6.it(0), con6.end(), are_ordered); + VERIFY( rv_array6[0] == 3 && rv_array6[1] == 3 && rv_array6[2] == 3 ); + + int array7[]={3,3}; + rvalstruct rv_array7[2]; + std::copy(array7, array7 + 2, rv_array7); + container con7(rv_array7, rv_array7 + 2); + std::inplace_merge(con7.begin(), con7.it(2), con7.end(), are_ordered); + VERIFY( rv_array7[0] == 3 && rv_array7[1] == 3 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..6cd2f17b4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void inplace_merge(iterator_type, iterator_type, iterator_type); + + template void inplace_merge(iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..95ea9671e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void inplace_merge(iterator_type, iterator_type, iterator_type); + + template void inplace_merge(iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap/1.cc new file mode 100644 index 000000000..605fc45ce --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-12 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include +#include +#include + +int A[] = {9, 8, 6, 7, 7, 5, 5, 3, 6, 4, 1, 2, 3, 4}; +int B[] = {1, 3, 2, 4, 4, 6, 3, 5, 5, 7, 7, 6, 8, 9}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + for (int i = 0; i <= N; ++i) + { + VERIFY( std::is_heap(A, A + i) ); + VERIFY( std::is_heap(A, A + i, std::less()) ); + VERIFY( std::is_heap(B, B + i, std::greater()) ); + VERIFY( (i < 2) || !std::is_heap(B, B + i) ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..847a32f8a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-12 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool is_heap(iterator_type, iterator_type); + template bool is_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..93099ba77 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-12 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool is_heap(iterator_type, iterator_type); + template bool is_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap_until/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/1.cc new file mode 100644 index 000000000..e4cc7a067 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-12 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include +#include +#include + +int A[] = {9, 8, 6, 7, 7, 5, 5, 3, 6, 4, 1, 2, 3, 4}; +int B[] = {1, 3, 2, 4, 4, 6, 3, 5, 5, 7, 7, 6, 8, 9}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + for (int i = 0; i <= N; ++i) + { + VERIFY( A + i == std::is_heap_until(A, A + i) ); + VERIFY( A + i == std::is_heap_until(A, A + i, std::less()) ); + VERIFY( B + i == std::is_heap_until(B, B + i, std::greater()) ); + VERIFY( B + (i < 2 ? i : 1) == std::is_heap_until(B, B + i) ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..d0df3ea2e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-12 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type is_heap_until(iterator_type, iterator_type); + template iterator_type is_heap_until(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..de2ba1398 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_heap_until/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-12 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type is_heap_until(iterator_type, iterator_type); + template iterator_type is_heap_until(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/1.cc new file mode 100644 index 000000000..3e5156d1b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/1.cc @@ -0,0 +1,80 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-27 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 1, 1, 1, 0, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::is_partitioned(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::is_partitioned(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 8); + VERIFY( !std::is_partitioned(con.begin(), con.end(), predicate) ); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + + Container con(array + 2, array + 7); + VERIFY( std::is_partitioned(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/check_type.cc new file mode 100644 index 000000000..41d14ecc8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/check_type.cc @@ -0,0 +1,49 @@ +// 2008-06-27 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::is_partitioned(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::is_partitioned(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..c36308482 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-27 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool is_partitioned(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..0edb004e6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_partitioned/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-27 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool is_partitioned(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/1.cc new file mode 100644 index 000000000..1ae227f14 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/1.cc @@ -0,0 +1,104 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-01-13 Paolo Carlini +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [alg.is_permutation] Is permutation + +#include +#include +#include + +struct my_equal_to +{ + bool + operator()(int __x, int __y) const + { return __x % 10 == __y % 10; } +}; + +const int arr0[] = { 11, 22, 33, 44, 55 }; + +void +do_test(int arr1[5], bool np = true) +{ + bool test __attribute__((unused)) = true; + + do + VERIFY( std::is_permutation(arr1, arr1 + 5, arr0) == np ); + while (std::next_permutation(arr1, arr1 + 5)); +} + +template + void + do_test(int arr1[5], Predicate pred, bool np = true) + { + bool test __attribute__((unused)) = true; + + do + VERIFY( std::is_permutation(arr1, arr1 + 5, arr0, pred) == np ); + while (std::next_permutation(arr1, arr1 + 5)); + } + +void test01() +{ + int arr1[] = { 11, 22, 33, 44, 55 }; + do_test(arr1); + + int arr2[] = { 11, 33, 33, 44, 55 }; + do_test(arr2, false); + + int arr3[] = { 33, 33, 33, 44, 44 }; + do_test(arr3, false); + + int arr4[] = { 11, 22, 33, 44, 55 }; + do_test(arr4, std::equal_to()); + + int arr5[] = { 11, 33, 33, 44, 55 }; + do_test(arr5, std::equal_to(), false); + + int arr6[] = { 33, 33, 33, 44, 44 }; + do_test(arr6, std::equal_to(), false); + + int arr7[] = { 1, 2, 3, 4, 5 }; + do_test(arr7, my_equal_to()); + + int arr8[] = { 1, 3, 3, 4, 5 }; + do_test(arr8, my_equal_to(), false); + + int arr9[] = { 3, 3, 3, 4, 4 }; + do_test(arr9, my_equal_to(), false); + + int arr10[] = { 111, 222, 333, 444, 555 }; + do_test(arr10, my_equal_to()); + + int arr11[] = { 1, 222, 33, 4, 55 }; + do_test(arr11, my_equal_to()); + + int arr12[] = { 111, 333, 333, 444, 555 }; + do_test(arr12, my_equal_to(), false); + + int arr13[] = { 333, 333, 333, 444, 444 }; + do_test(arr13, my_equal_to(), false); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type.cc new file mode 100644 index 000000000..600c09d6b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/check_type.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// 2011-01-13 Paolo Carlini +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [alg.is_permutation] Is permutation + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; +bool operator==(const X&, const X) { return true; } + +struct Y { }; +bool predicate(const Y&, const Y&) { return true; } + +bool +test1(forward_iterator_wrapper& x1, + forward_iterator_wrapper& x2) +{ + return std::is_permutation(x1, x1, x2); +} + +bool +test2(forward_iterator_wrapper& y1, + forward_iterator_wrapper& y2) +{ + return std::is_permutation(y1, y1, y2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..1d629d490 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-01-13 Paolo Carlini +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function + predicate_type; + + template bool is_permutation(iterator_type, iterator_type, + iterator_type); + + template bool is_permutation(iterator_type, iterator_type, + iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..fcf878afb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2011-01-13 Paolo Carlini +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function + predicate_type; + + template bool is_permutation(iterator_type, iterator_type, + iterator_type); + + template bool is_permutation(iterator_type, iterator_type, + iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc new file mode 100644 index 000000000..87efdeff3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include +#include +#include + +int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +int B[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + for (int i = 0; i <= N; ++i) + { + VERIFY( std::is_sorted(A, A + i) ); + VERIFY( std::is_sorted(A, A + i, std::less()) ); + VERIFY( std::is_sorted(B, B + i, std::greater()) ); + VERIFY( (i < 2) || !std::is_sorted(B, B + i) ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..e702c4fbe --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool is_sorted(iterator_type, iterator_type); + template bool is_sorted(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2ffa35fae --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool is_sorted(iterator_type, iterator_type); + template bool is_sorted(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc new file mode 100644 index 000000000..cb756ca4f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/1.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini +// +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +#include +#include +#include + +int A[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +int B[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; +const int N = sizeof(A) / sizeof(int); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + for (int i = 0; i <= N; ++i) + { + VERIFY( A + i == std::is_sorted_until(A, A + i) ); + VERIFY( A + i == std::is_sorted_until(A, A + i, std::less()) ); + VERIFY( B + i == std::is_sorted_until(B, B + i, std::greater()) ); + VERIFY( B + (i < 2 ? i : 1) == std::is_sorted_until(B, B + i) ); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..09effddcd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type is_sorted_until(iterator_type, iterator_type); + template iterator_type is_sorted_until(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2333707d3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_sorted_until/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-14 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type is_sorted_until(iterator_type, iterator_type); + template iterator_type is_sorted_until(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/iter_swap/20577.cc b/libstdc++-v3/testsuite/25_algorithms/iter_swap/20577.cc new file mode 100644 index 000000000..ee084eb97 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/iter_swap/20577.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void +test1() +{ + bool test __attribute__((unused)) = true; + + std::vector v; + v.push_back(true); + v.push_back(false); + std::iter_swap(v.begin(), v.begin() + 1); + VERIFY( v[0] == false && v[1] == true ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + std::vector v; + v.push_back(1); + v.push_back(2); + std::iter_swap(v.begin(), v.begin() + 1); + VERIFY( v[0] == 2 && v[1] == 1 ); +} + +int int_swap_count; + +struct X {}; +void swap(X&, X&) +{ ++int_swap_count; } + +void +test3() +{ + bool test __attribute__((unused)) = true; + + int_swap_count = 0; + X i, j; + std::iter_swap(&i, &j); + VERIFY( int_swap_count == 1 ); +} + +// libstdc++/20577 +int main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..822c69ccf --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template void iter_swap(iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..b7e4a16ba --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/iter_swap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template void iter_swap(iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc new file mode 100644 index 000000000..8b5e62d36 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.8 [lib.alg.lex.comparison] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0, 1}; + +void +test1() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( !std::lexicographical_compare(con1.begin(), con1.end(), + con2.begin(), con2.end()) ); +} + +void +test2() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::lexicographical_compare(con1.begin(), con1.end(), + con2.begin(), con2.end()) ); +} + +void +test3() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::lexicographical_compare(con2.begin(), con2.end(), + con1.begin(), con1.end()) ); +} + +void +test4() +{ + Container con3(array3, array3 + 3); + Container con2(array2, array2 + 2); + VERIFY( std::lexicographical_compare(con2.begin(), con2.end(), + con3.begin(), con3.end()) ); +} + +void +test5() +{ + Container con3(array3, array3 + 3); + Container con2(array2, array2 + 2); + VERIFY( !std::lexicographical_compare(con3.begin(), con3.end(), + con2.begin(), con2.end()) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc new file mode 100644 index 000000000..f8643aa2d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.8 [lib.alg.lex.comparison] + +// { dg-do compile } + + +#include +#include + +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool +operator<(const Lhs1&, const Rhs1&) {return true;} + +bool +operator<(const Rhs1&, const Lhs1&) {return false;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(input_iterator_wrapper& lhs1, + input_iterator_wrapper& rhs1) +{ return std::lexicographical_compare(lhs1, lhs1, rhs1, rhs1); } + +bool +test2(input_iterator_wrapper& x) +{ return std::lexicographical_compare(x, x, x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..806e5ca69 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool lexicographical_compare(iterator_type, iterator_type, + iterator_type, iterator_type); + + template bool lexicographical_compare(iterator_type, iterator_type, + iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2cb90612b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool lexicographical_compare(iterator_type, iterator_type, + iterator_type, iterator_type); + + template bool lexicographical_compare(iterator_type, iterator_type, + iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc new file mode 100644 index 000000000..7a2cd6d29 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.1 [lib.lower.bound] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::lower_bound; + +typedef test_container Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1}; + +void +test1() +{ + for(int i = 0; i < 5; ++i) + for(int j = 4; j < 7; ++j) + { + Container con(array + i, array + j); + VERIFY(lower_bound(con.begin(), con.end(), 1).ptr == array + 4); + } +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/2.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/2.cc new file mode 100644 index 000000000..00e838241 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/2.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3 [lib.alg.binary.search] Binary search algorithms. + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 3, 3, 5, 8}; +const int C[] = {8, 5, 3, 3, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); + +// A comparison, equalivalent to std::greater without the +// dependency on . +struct gt +{ + bool + operator()(const int& x, const int& y) const + { return x > y; } +}; + +// Each test performs general-case, bookend, not-found condition, +// and predicate functional checks. + +// 25.3.3.1 lower_bound, with and without comparison predicate +void +test01() +{ + using std::lower_bound; + + const int first = A[0]; + const int last = A[N - 1]; + + const int* p = lower_bound(A, A + N, 3); + VERIFY(p == A + 2); + + const int* q = lower_bound(A, A + N, first); + VERIFY(q == A + 0); + + const int* r = lower_bound(A, A + N, last); + VERIFY(r == A + N - 1); + + const int* s = lower_bound(A, A + N, 4); + VERIFY(s == A + 5); + + const int* t = lower_bound(C, C + N, 3, gt()); + VERIFY(t == C + 2); + + const int* u = lower_bound(C, C + N, first, gt()); + VERIFY(u == C + N - 1); + + const int* v = lower_bound(C, C + N, last, gt()); + VERIFY(v == C + 0); + + const int* w = lower_bound(C, C + N, 4, gt()); + VERIFY(w == C + 2); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/33613.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/33613.cc new file mode 100644 index 000000000..1358b4d9f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/33613.cc @@ -0,0 +1,36 @@ +// 2007-10-02 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/33613 + +#include + +struct A { }; +struct B { }; + +bool ab(A, B); + +void test01(A* a, B b) +{ + std::lower_bound(a, a, b, ab); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc new file mode 100644 index 000000000..a3d770f22 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.1 [lib.lower.bound] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& s) +{ return std::lower_bound(s, s, *s); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x) +{ return std::lower_bound(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/no_operator_ne.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/no_operator_ne.cc new file mode 100644 index 000000000..1abbbb0d7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/no_operator_ne.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// Copyright (C) 2000, 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// http://gcc.gnu.org/ml/libstdc++/2000-06/msg00316.html +struct foo { }; + +bool operator== (const foo&, const foo&) { return true; }; +bool operator< (const foo&, const foo&) { return true; }; + +void bar(foo* a, foo* b, foo& x) +{ + foo* c __attribute__((unused)) = std::lower_bound(a, b, x); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..65f80db71 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type lower_bound(iterator_type, iterator_type, + const value_type&); + + template iterator_type lower_bound(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..191f7348a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type lower_bound(iterator_type, iterator_type, + const value_type&); + + template iterator_type lower_bound(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..cb583ea21 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void make_heap(iterator_type, iterator_type); + template void make_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..b78f647f0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/make_heap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void make_heap(iterator_type, iterator_type); + template void make_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/1.cc b/libstdc++-v3/testsuite/25_algorithms/max/1.cc new file mode 100644 index 000000000..978466f1b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/1.cc @@ -0,0 +1,43 @@ +// 2000-03-29 sss/bkoz + +// Copyright (C) 2000, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const int& x = std::max(1, 2); + const int& y = std::max(4, 3); + VERIFY( x == 2 ); + VERIFY( y == 4 ); + + const int& xc = std::max(1, 2, std::greater()); + const int& yc = std::max(4, 3, std::greater()); + VERIFY( xc == 1 ); + VERIFY( yc == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/2.cc b/libstdc++-v3/testsuite/25_algorithms/max/2.cc new file mode 100644 index 000000000..0752c8cce --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/2.cc @@ -0,0 +1,77 @@ +// 2000-03-29 sss/bkoz + +// Copyright (C) 2000, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +template + struct A { static const T a; }; + +template +const T A::a = T(3); + +void test02() +{ + bool test __attribute__((unused)) = true; + + VERIFY( 3 == std::max(A::a, 2) ); + VERIFY( 4 == std::max(A::a, 4) ); + + VERIFY( 3u == std::max(A::a, 2u) ); + VERIFY( 4u == std::max(A::a, 4u) ); + + VERIFY( 3l == std::max(A::a, 2l) ); + VERIFY( 4l == std::max(A::a, 4l) ); + + VERIFY( 3ul == std::max(A::a, 2ul) ); + VERIFY( 4ul == std::max(A::a, 4ul) ); + +#ifdef _GLIBCXX_USE_LONG_LONG + VERIFY( 3ll == std::max(A::a, 2ll) ); + VERIFY( 4ll == std::max(A::a, 4ll) ); + + VERIFY( 3ull == std::max(A::a, 2ull) ); + VERIFY( 4ull == std::max(A::a, 4ull) ); +#endif + + VERIFY( short(3) == std::max(A::a, short(2)) ); + VERIFY( short(4) == std::max(A::a, short(4)) ); + + VERIFY( (unsigned short)3 == std::max(A::a, (unsigned short)2) ); + VERIFY( (unsigned short)4 == std::max(A::a, (unsigned short)4) ); + + VERIFY( (char)3 == std::max(A::a, (char)2) ); + VERIFY( (char)4 == std::max(A::a, (char)4) ); + + VERIFY( (signed char)3 == std::max(A::a, (signed char)2) ); + VERIFY( (signed char)4 == std::max(A::a, (signed char)4) ); + + VERIFY( (unsigned char)3 == std::max(A::a, (unsigned char)2) ); + VERIFY( (unsigned char)4 == std::max(A::a, (unsigned char)4) ); + + VERIFY( (wchar_t)3 == std::max(A::a, (wchar_t)2) ); + VERIFY( (wchar_t)4 == std::max(A::a, (wchar_t)4) ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/3.cc b/libstdc++-v3/testsuite/25_algorithms/max/3.cc new file mode 100644 index 000000000..7025bb874 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/3.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const int& x = std::max({1, 3, 2}); + const int& y = std::max({4, 3, 2}); + const int& z = std::max({3, 2, 4}); + VERIFY( x == 3 ); + VERIFY( y == 4 ); + VERIFY( z == 4 ); + + const int& xc = std::max({1, 2, 3}, std::greater()); + const int& yc = std::max({4, 3, 2}, std::greater()); + const int& zc = std::max({2, 4, 3}, std::greater()); + VERIFY( xc == 1 ); + VERIFY( yc == 2 ); + VERIFY( zc == 2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/37547.cc b/libstdc++-v3/testsuite/25_algorithms/max/37547.cc new file mode 100644 index 000000000..91e010f9e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/37547.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/37547 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector v{1,2,3,4,5}; + + auto p = std::max({v}); + VERIFY ( p == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/4.cc b/libstdc++-v3/testsuite/25_algorithms/max/4.cc new file mode 100644 index 000000000..fdfa2e59f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/4.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const int& z = std::max({1, 2, 3, 4, 5, 6, 7}); + const double& w = std::max({2.0, 1.0, 3.2, 4.5, 5.0, 6.0, 7.0}); + const int& y = std::max({2, 3, 1, 4, 5, 6, 7}); + const float& x = std::max({2.0f, 3.0f, 5.0f, 1.0f, 7.0f, 6.0f}); + VERIFY( z == 7 ); + VERIFY( w == 7.0 ); + VERIFY( y == 7 ); + VERIFY( x == 7.0f ); + + const int& zc = std::max({1, 2, 3, 4, 5, 6, 7}, std::greater()); + const double& wc = std::max({2.0, 1.0, 3.2, 4.5, 5.0}, + std::greater()); + const int& yc = std::max({2, 7, 1, 4, 5, 6, 3}, std::greater()); + const float& xc = std::max({2.0f, 3.0f, 5.0f, 1.0f}, + std::greater()); + + VERIFY( zc == 1 ); + VERIFY( wc == 1.0 ); + VERIFY( yc == 1 ); + VERIFY( xc == 1.0f ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..da5abece2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template const value_type& max(const value_type&, const value_type&); + + template const value_type& max(const value_type&, const value_type&, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..e99f53990 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/3.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template value_type max(initializer_list); + template value_type max(initializer_list, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..7c704367f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template const value_type& max(const value_type&, const value_type&); + + template const value_type& max(const value_type&, const value_type&, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc new file mode 100644 index 000000000..ae9322142 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max/requirements/explicit_instantiation/pod2.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template value_type max(initializer_list); + template value_type max(initializer_list, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc new file mode 100644 index 000000000..1db08994d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.7 [lib.alg.min.max] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::max_element; + +typedef test_container Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test3() +{ + int array[] = {3, 0}; + Container con(array, array + 2); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test4() +{ + int array[] = {0, 3, 6, 2, 6, 4, 0}; + Container con(array, array + 7); + VERIFY(max_element(con.begin(), con.end()).ptr == array + 2); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc new file mode 100644 index 000000000..b7917e268 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.7 [lib.alg.min.max] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& s) +{ return std::max_element(s, s); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x) +{ return std::max_element(x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ca8701766 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type max_element(iterator_type, iterator_type); + + template iterator_type max_element(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..7dd0c791f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type max_element(iterator_type, iterator_type); + + template iterator_type max_element(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/1.cc b/libstdc++-v3/testsuite/25_algorithms/merge/1.cc new file mode 100644 index 000000000..7b6a1e890 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/1.cc @@ -0,0 +1,100 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.4 [lib.alg.merge] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::merge; + +typedef test_container Icontainer; +typedef test_container Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(merge(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[]={0,1,4}; + int array2[]={2,3}; + int array3[5]; + Icontainer con1(array1, array1 + 3); + Icontainer con2(array2, array2 + 2); + Ocontainer con3(array3, array3 + 5); + VERIFY(merge(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 5); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 2 && + array3[3] == 3 && array3[4] == 4); + +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +void +test3() +{ + S array1[] = { -1 , -3}; + S array2[] = { 1, 2, 3}; + S array3[5]; + merge(array1, array1 + 2, array2, array2 + 3, array3); + VERIFY(array3[0].j == 0 && array3[1].j == 1 && array3[2].j == 1 && + array3[3].j == 0 && array3[4].j == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc new file mode 100644 index 000000000..d22693552 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.4 [lib.alg.merge] + +// { dg-do compile } + +#include +#include +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper +test1(input_iterator_wrapper& in, + output_iterator_wrapper& out) +{ return std::merge(in, in, in, in, out); } + +output_iterator_wrapper +test2(input_iterator_wrapper& in, + output_iterator_wrapper& out) +{ return std::merge(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..a9de8e64e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type merge(iterator_type, iterator_type, + iterator_type, iterator_type, iterator_type); + + template iterator_type merge(iterator_type, iterator_type, iterator_type, + iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..a18b0c86a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type merge(iterator_type, iterator_type, + iterator_type, iterator_type, iterator_type); + + template iterator_type merge(iterator_type, iterator_type, iterator_type, + iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/1.cc b/libstdc++-v3/testsuite/25_algorithms/min/1.cc new file mode 100644 index 000000000..23bc72161 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/1.cc @@ -0,0 +1,43 @@ +// 2000-03-29 sss/bkoz + +// Copyright (C) 2000, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const int& z = std::min(1, 2); + const int& w = std::min(4, 3); + VERIFY( z == 1 ); + VERIFY( w == 3 ); + + const int& zc = std::min(1, 2, std::greater()); + const int& wc = std::min(4, 3, std::greater()); + VERIFY( zc == 2 ); + VERIFY( wc == 4 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/2.cc b/libstdc++-v3/testsuite/25_algorithms/min/2.cc new file mode 100644 index 000000000..dcfd41a18 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/2.cc @@ -0,0 +1,86 @@ +// 2000-03-29 sss/bkoz + +// Copyright (C) 2000, 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +template + struct A { static const T a; }; + +template +const T A::a = T(3); + +void test02() +{ + bool test __attribute__((unused)) = true; + + VERIFY( 2 == std::min(A::a, 2) ); + VERIFY( 3 == std::min(A::a, 4) ); + + VERIFY( 2u == std::min(A::a, 2u) ); + VERIFY( 3u == std::min(A::a, 4u) ); + + VERIFY( 2l == std::min(A::a, 2l) ); + VERIFY( 3l == std::min(A::a, 4l) ); + + VERIFY( 2ul == std::min(A::a, 2ul) ); + VERIFY( 3ul == std::min(A::a, 4ul) ); + +#ifdef _GLIBCXX_USE_LONG_LONG + VERIFY( 2ll == std::min(A::a, 2ll) ); + VERIFY( 3ll == std::min(A::a, 4ll) ); + + VERIFY( 2ull == std::min(A::a, 2ull) ); + VERIFY( 3ull == std::min(A::a, 4ull) ); +#endif + + VERIFY( short(2) == std::min(A::a, short(2)) ); + VERIFY( short(3) == std::min(A::a, short(4)) ); + + VERIFY( (unsigned short)2 == std::min(A::a, (unsigned short)2) ); + VERIFY( (unsigned short)3 == std::min(A::a, (unsigned short)4) ); + + VERIFY( (char)2 == std::min(A::a, (char)2) ); + VERIFY( (char)3 == std::min(A::a, (char)4) ); + + VERIFY( (signed char)2 == std::min(A::a, (signed char)2) ); + VERIFY( (signed char)3 == std::min(A::a, (signed char)4) ); + + VERIFY( (unsigned char)2 == std::min(A::a, (unsigned char)2) ); + VERIFY( (unsigned char)3 == std::min(A::a, (unsigned char)4) ); + + VERIFY( (wchar_t)2 == std::min(A::a, (wchar_t)2) ); + VERIFY( (wchar_t)3 == std::min(A::a, (wchar_t)4) ); + + VERIFY( 2.0 == std::min(A::a, 2.0) ); + VERIFY( 3.0 == std::min(A::a, 4.0) ); + + VERIFY( float(2) == std::min(A::a, float(2)) ); + VERIFY( float(3) == std::min(A::a, float(4)) ); + + VERIFY( (long double)2 == std::min(A::a, (long double)2) ); + VERIFY( (long double)3 == std::min(A::a, (long double)4) ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/3.cc b/libstdc++-v3/testsuite/25_algorithms/min/3.cc new file mode 100644 index 000000000..e76700d28 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/3.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const int& z = std::min({1, 3, 2}); + const int& w = std::min({4, 3, 5}); + const int& y = std::min({4, 3, 2}); + VERIFY( z == 1 ); + VERIFY( w == 3 ); + VERIFY( y == 2 ); + + const int& zc = std::min({1, 3, 2}, std::greater()); + const int& wc = std::min({4, 3, 5}, std::greater()); + const int& yc = std::min({4, 3, 2}, std::greater()); + VERIFY( zc == 3 ); + VERIFY( wc == 5 ); + VERIFY( yc == 4 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/37547.cc b/libstdc++-v3/testsuite/25_algorithms/min/37547.cc new file mode 100644 index 000000000..ddca88338 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/37547.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/37547 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector v{1,2,3,4,5}; + + auto p = std::min({v}); + VERIFY ( p == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/4.cc b/libstdc++-v3/testsuite/25_algorithms/min/4.cc new file mode 100644 index 000000000..5593d249b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/4.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const int& z = std::min({1, 2, 3, 4, 5, 6, 7}); + const double& w = std::min({2.0, 1.0, 3.2, 4.5, 5.0, 6.0, 7.0}); + const int& y = std::min({2, 3, 1, 4, 5, 6, 7}); + const float& x = std::min({2.0f, 3.0f, 5.0f, 1.0f, 7.0f, 6.0f}); + VERIFY( z == 1 ); + VERIFY( w == 1.0 ); + VERIFY( y == 1 ); + VERIFY( x == 1.0f ); + + + const int& zc = std::min({1, 2, 3, 4, 5, 6, 7}, std::greater()); + const double& wc = std::min({2.0, 1.0, 3.2, 4.5, 5.0, 6.0, 7.0}, + std::greater()); + const int& yc = std::min({2, 7, 1, 4, 5, 6, 3}, std::greater()); + const float& xc = std::min({2.0f, 3.0f, 5.0f, 1.0f, 7.0f, 6.0f}, + std::greater()); + + VERIFY( zc == 7 ); + VERIFY( wc == 7.0 ); + VERIFY( yc == 7 ); + VERIFY( xc == 7.0f ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..c118f4da2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template const value_type& min(const value_type&, const value_type&); + template const value_type& min(const value_type&, const value_type&, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..ce2dbcfc4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/3.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template value_type min(initializer_list); + template value_type min(initializer_list, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..78ca02d47 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template const value_type& min(const value_type&, const value_type&); + template const value_type& min(const value_type&, const value_type&, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc new file mode 100644 index 000000000..8080ddc09 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min/requirements/explicit_instantiation/pod2.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template value_type min(initializer_list); + template value_type min(initializer_list, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc new file mode 100644 index 000000000..8c609dcd5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc @@ -0,0 +1,70 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.7 [lib.alg.min.max] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::min_element; + +typedef test_container Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test3() +{ + int array[] = {0, 3}; + Container con(array, array + 2); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test4() +{ + int array[] = {6, 3, 0, 2, 6, 4, 0}; + Container con(array, array + 7); + VERIFY(min_element(con.begin(), con.end()).ptr == array + 2); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc new file mode 100644 index 000000000..191b55640 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.7 [lib.alg.min.max] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& s) +{ return std::min_element(s,s); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x) +{ return std::min_element(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..5ec4c2ad5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type min_element(iterator_type, iterator_type); + + template iterator_type min_element(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..bc1bdb20a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type min_element(iterator_type, iterator_type); + + template iterator_type min_element(iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/1.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/1.cc new file mode 100644 index 000000000..52122415e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/1.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-11-01 Paolo Carlini . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair z = std::minmax(1, 2); + std::pair w = std::minmax(4, 3); + VERIFY( z.first == 1 ); + VERIFY( z.second == 2 ); + VERIFY( w.first == 3 ); + VERIFY( w.second == 4 ); + + std::pair zc = std::minmax(1, 2, std::greater()); + std::pair wc = std::minmax(4, 3, std::greater()); + VERIFY( zc.first == 2 ); + VERIFY( zc.second == 1 ); + VERIFY( wc.first == 4 ); + VERIFY( wc.second == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc new file mode 100644 index 000000000..6c4200eef --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc @@ -0,0 +1,61 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::pair z = std::minmax({1, 2, 3}); + std::pair w = std::minmax({4, 3, 5, 4}); + std::pair y = std::minmax({4, 5, 3, 7, 3}); + VERIFY( z.first == 1 ); + VERIFY( z.second == 3 ); + VERIFY( w.first == 3 ); + VERIFY( w.second == 5 ); + VERIFY( y.first == 3 ); + VERIFY( y.second == 7 ); + + std::pair zc = + std::minmax({1, 2, 3}, std::greater()); + + std::pair wc = + std::minmax({4, 3, 5, 4}, std::greater()); + + std::pair yc = + std::minmax({4, 5, 3, 7, 3}, std::greater()); + + VERIFY( zc.first == 3 ); + VERIFY( zc.second == 1 ); + VERIFY( wc.first == 5 ); + VERIFY( wc.second == 3 ); + VERIFY( yc.first == 7 ); + VERIFY( yc.second == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc new file mode 100644 index 000000000..0e99d51d2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +struct compare_counter + : std::binary_function +{ + static int count; + + bool operator()(int a, int b) const + { + ++count; + return a < b; + } +}; + +int compare_counter::count = 0; + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::minmax({1, 2, 3, 4, 5, 6, 7, 8}, compare_counter()); + + // If N is the number of arguments in the minmax function call, + // 25.3.7 specifies that at most 3N/2 comparisons are allowed. + VERIFY(compare_counter::count <= (3 * 8 / 2)); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc new file mode 100644 index 000000000..1c7748bfc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/37547.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/37547 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::vector v{1,2,3,4,5}; + + auto p = std::minmax({v}); + VERIFY ( p.first == v ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..c20ae4bb8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-11-01 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template pair + minmax(const value_type&, const value_type&); + template pair + minmax(const value_type&, const value_type&, compare_type); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..d133f8cbe --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/3.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template pair minmax(initializer_list); + template pair minmax(initializer_list, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..8f6da5dcc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-11-01 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template pair + minmax(const value_type&, const value_type&); + template pair + minmax(const value_type&, const value_type&, compare_type); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc new file mode 100644 index 000000000..af579651a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax/requirements/explicit_instantiation/pod2.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2008-09-16 Chris Fairles + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template pair minmax(initializer_list); + template pair minmax(initializer_list, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/minmax_element/1.cc new file mode 100644 index 000000000..65662d03d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax_element/1.cc @@ -0,0 +1,138 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::minmax_element; + +typedef test_container Container; +typedef std::pair, forward_iterator_wrapper > pair_type; + +void +test1() +{ + bool test __attribute__((unused)) = true; + + int array[] = {0}; + Container con(array, array); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array ); + VERIFY( p1.second.ptr == array ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + int array[] = {0}; + Container con(array, array + 1); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array ); + VERIFY( p1.second.ptr == array ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + int array[] = {0, 3}; + Container con(array, array + 2); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array ); + VERIFY( p1.second.ptr == array + 1 ); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + + int array[] = {3, 0}; + Container con(array, array + 2); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array + 1 ); + VERIFY( p1.second.ptr == array ); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + + int array[] = {3, 3}; + Container con(array, array + 2); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array ); + VERIFY( p1.second.ptr == array + 1 ); +} + +void +test6() +{ + bool test __attribute__((unused)) = true; + + int array[] = {6, 3, 0, 2, 6, 4, 0}; + Container con(array, array + 7); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array + 2 ); + VERIFY( p1.second.ptr == array + 4 ); +} + +void +test7() +{ + bool test __attribute__((unused)) = true; + + int array[] = {4, 4, 4, 6, 6, 6, 1, 1, 0, 0, 0, 2, 2}; + Container con(array, array + 13); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array + 8 ); + VERIFY( p1.second.ptr == array + 5 ); +} + +void +test8() +{ + bool test __attribute__((unused)) = true; + + int array[] = {1, 7, 5, 5, 10, 1, 0, 0, 8, 4, 4, 0, 10, 10, 10, 1}; + Container con(array, array + 16); + pair_type p1 = minmax_element(con.begin(), con.end()); + VERIFY( p1.first.ptr == array + 6 ); + VERIFY( p1.second.ptr == array + 14 ); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/minmax_element/check_type.cc new file mode 100644 index 000000000..3cd46259c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax_element/check_type.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +std::pair, forward_iterator_wrapper > +test1(forward_iterator_wrapper& s) +{ return std::minmax_element(s,s); } + +std::pair, forward_iterator_wrapper > +test2(forward_iterator_wrapper& x) +{ return std::minmax_element(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..5e03b5e39 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-11-01 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template pair + minmax_element(iterator_type, iterator_type); + template pair + minmax_element(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..17a1e85b5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/minmax_element/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-11-01 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template pair + minmax_element(iterator_type, iterator_type); + template pair + minmax_element(iterator_type, iterator_type, compare_type); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc new file mode 100644 index 000000000..e20349e1a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc @@ -0,0 +1,88 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.7 [lib.mismatch] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0, 1}; + +void test1a() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr + == array1 ); +} + +void test1b() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr + == array2 ); +} + +void test2a() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr + == array1 ); +} + +void test2b() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr + == array2 ); +} + +void test3a() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).first.ptr + == array3 + 2 ); +} + +void test3b() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).second.ptr + == array2 + 2 ); +} + +int main() +{ + test1a(); + test1b(); + test2a(); + test2b(); + test3a(); + test3b(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc new file mode 100644 index 000000000..cb07805c7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.7 [lib.mismatch] + +// { dg-do compile } + +#include +#include +#include + +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct Lhs2 { }; + +struct Rhs2 { }; + +bool predicate(const Lhs2&, const Rhs2&) {return true;} + +std::pair, input_iterator_wrapper > +test1(input_iterator_wrapper& lhs1, input_iterator_wrapper& rhs1) +{ + return std::mismatch(lhs1, lhs1, rhs1); +} + +std::pair, input_iterator_wrapper > +test2(input_iterator_wrapper& lhs2, input_iterator_wrapper& rhs2) +{ + return std::mismatch(lhs2, lhs2, rhs2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/1.cc b/libstdc++-v3/testsuite/25_algorithms/move/1.cc new file mode 100644 index 000000000..65c42d12d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/1.cc @@ -0,0 +1,62 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::move; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + std::fill(out, out + size, 0); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + move(incon.begin(), incon.end(), outcon.begin()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/1.cc new file mode 100644 index 000000000..a97dfc011 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/deque_iterators/1.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-12-23 Paolo Carlini +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque data(200); + for (unsigned i = 0; i < data.size(); ++i) + data[i] = i; + + const deque data_1(data.size(), -1); + + for (unsigned i = 0; i < data.size(); i += 2) + for (unsigned j = i; j <= data.size(); j += 3) + for (unsigned k = 0; k + (j - i) <= data.size(); k += 5) + { + deque d(data.size(), -1); + move(data.begin() + i, data.begin() + j, d.begin() + k); + + VERIFY( equal(data.begin() + i, data.begin() + j, + d.begin() + k) ); + VERIFY( equal(d.begin(), d.begin() + k, data_1.begin()) ); + VERIFY( equal(d.begin() + k + (j - i), d.end(), data_1.begin()) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..b75908d49 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-19 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type move(iterator_type, iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..7129df020 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-19 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type move(iterator_type, iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/1.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/1.cc new file mode 100644 index 000000000..211200466 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/1.cc @@ -0,0 +1,64 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::move_backward; + +typedef test_container container_in; +typedef test_container container_out; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int inarray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + const int size = sizeof(inarray) / sizeof(int); + + rvalstruct in[size], out[size]; + std::copy(inarray, inarray + size, in); + std::fill(out, out + size, 0); + + container_in incon(in, in + size); + container_out outcon(out, out + size); + + move_backward(incon.begin(), incon.end(), outcon.end()); + VERIFY( std::equal(out, out + size, inarray) ); + for (int z = 0; z < size; ++z) + VERIFY( out[z].valid ); + for (int z = 0; z < size; ++z) + VERIFY( !in[z].valid ); +} + + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/1.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/1.cc new file mode 100644 index 000000000..f695a6d72 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/deque_iterators/1.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } + +// 2009-12-24 Paolo Carlini +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + deque data(200); + for (unsigned i = 0; i < data.size(); ++i) + data[i] = i; + + const deque data_1(data.size(), -1); + + for (unsigned i = 0; i < data.size(); i += 2) + for (unsigned j = i; j <= data.size(); j += 3) + for (unsigned k = 0; k + (j - i) <= data.size(); k += 5) + { + deque d(data.size(), -1); + move_backward(data.begin() + i, data.begin() + j, + d.begin() + k + (j - i)); + + VERIFY( equal(data.begin() + i, data.begin() + j, + d.begin() + k) ); + VERIFY( equal(d.begin(), d.begin() + k, data_1.begin()) ); + VERIFY( equal(d.begin() + k + (j - i), d.end(), data_1.begin()) ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..a51b342a2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-19 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type move_backward(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..9a7e5b902 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move_backward/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-10-19 Paolo Carlini + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type move_backward(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc new file mode 100644 index 000000000..e00ca261a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc @@ -0,0 +1,83 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.9 [lib.alg.permutation.generators] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::next_permutation; + +typedef test_container Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(!next_permutation(con.begin(), con.end())); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(!next_permutation(con.begin(), con.end())); +} + +void +test3() +{ + int array[] = {0, 3}; + Container con(array, array + 2); + VERIFY(next_permutation(con.begin(), con.end())); + VERIFY(array[0] == 3 && array[1] == 0); + VERIFY(!next_permutation(con.begin(), con.end())); + VERIFY(array[0] == 0 && array[1] == 3); +} + +void +test4() +{ + int array[6] = {0, 1, 2, 3, 4, 5}; + Container con(array, array + 6); + for(int i = 0 ; i < 719; ++i) + { + int temp_array[6]; + std::copy(array, array + 6, temp_array); + VERIFY(next_permutation(array, array + 6)); + VERIFY(std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6)); + } + VERIFY(!next_permutation(array,array + 6)); + for(int i = 0; i < 6; ++i) + VERIFY(array[i] == i); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc new file mode 100644 index 000000000..efd3c20d5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.9 [lib.alg.permutation.generators] + +// { dg-do compile } + +#include +#include + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(bidirectional_iterator_wrapper& s) +{ return std::next_permutation(s,s); } + +bool +test2(bidirectional_iterator_wrapper& x) +{ return std::next_permutation(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/moveable.cc new file mode 100644 index 000000000..a227e1377 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/moveable.cc @@ -0,0 +1,125 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.9 [lib.alg.permutation.generators] + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::next_permutation; + +typedef test_container Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + rvalstruct array[] = {0}; + Container con(array, array); + VERIFY( !next_permutation(con.begin(), con.end()) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + rvalstruct array[] = {0}; + Container con(array, array + 1); + VERIFY( !next_permutation(con.begin(), con.end()) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + rvalstruct array[] = {0, 3}; + Container con(array, array + 2); + VERIFY( next_permutation(con.begin(), con.end()) ); + VERIFY( array[0] == 3 && array[1] == 0 ); + VERIFY( !next_permutation(con.begin(), con.end()) ); + VERIFY( array[0] == 0 && array[1] == 3 ); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + + int array[6] = {0, 1, 2, 3, 4, 5}; + for(int i = 0 ; i < 719; ++i) + { + rvalstruct temp_array[6]; + std::copy(array, array + 6, temp_array); + Container con(temp_array, temp_array + 6); + VERIFY( next_permutation(array, array + 6) ); + VERIFY( std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6) ); + } + VERIFY( !next_permutation(array,array + 6) ); + for(int i = 0; i < 6; ++i) + VERIFY( array[i] == i ); +} + +bool +are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test5() +{ + bool test __attribute__((unused)) = true; + + int array[6] = {0, 1, 2, 3, 4, 5}; + for(int i = 0 ; i < 719; ++i) + { + rvalstruct temp_array[6]; + std::copy(array, array + 6, temp_array); + Container con(temp_array, temp_array + 6); + VERIFY( next_permutation(array, array + 6, are_ordered) ); + VERIFY( std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6, are_ordered) ); + } + VERIFY( !next_permutation(array,array + 6, are_ordered) ); + for(int i = 0; i < 6; ++i) + VERIFY( array[i] == i ); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ed8387270 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool next_permutation(iterator_type, iterator_type); + template bool next_permutation(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..d63f0e04d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool next_permutation(iterator_type, iterator_type); + template bool next_permutation(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/1.cc new file mode 100644 index 000000000..07b7adac2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/1.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + VERIFY( std::none_of(con.begin(), con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + VERIFY( std::none_of(con.begin(), con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + VERIFY( !std::none_of(con.begin(), con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc new file mode 100644 index 000000000..55d158dee --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/check_type.cc @@ -0,0 +1,49 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +bool +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::none_of(begin, end, pred_function); } + +bool +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end) +{ return std::none_of(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..04de07b2d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool none_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..ad3f92066 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/none_of/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template bool none_of(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc new file mode 100644 index 000000000..6f6b508cd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc @@ -0,0 +1,81 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.2 [lib.alg.nth.element] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::nth_element; +using std::partial_sort; + +typedef test_container Container; + +void +test1() +{ + int array[]={0}; + Container con(array, array); + partial_sort(con.begin(), con.begin(), con.end()); +} + +void +test2() +{ + int array[]={2,1,0}; + Container con(array, array + 2); + partial_sort(con.begin(), con.begin(), con.end()); + partial_sort(con.begin(), con.end(), con.end()); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY(array[i] < array[3]); + for(int i = 4; i < 7; ++i) + VERIFY(array[3] < array[i]); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 6, 1, 5, 2, 4, 3}; + Container con(array,array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY(array[i] < array[3]); + for(int i = 4; i < 7; ++i) + VERIFY(array[3] < array[i]); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/2.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/2.cc new file mode 100644 index 000000000..248c77be8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/2.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.2 [lib.alg.nth.element] + +// { dg-options "-DMAX_SIZE=256" { target simulator } } + +#ifndef MAX_SIZE +#define MAX_SIZE (1 << 10) +#endif + +#include +#include +#include + +void +test_set(std::vector& v, unsigned size) +{ + v.clear(); + + for (unsigned i = 0; i < size; i += 4) + { + v.push_back(i / 2); + v.push_back((size - 2) - (i / 2)); + } + for (unsigned i = 1; i < size; i += 2) + v.push_back(i); +} + +void +do_test01(unsigned size) +{ + bool test __attribute__((unused)) = true; + + std::vector v, s; + + for (unsigned j = 0; j < size; ++j) + { + test_set(v, size); + s = v; + std::sort(s.begin(), s.end()); + + std::nth_element(v.begin(), v.begin() + j, v.end()); + + VERIFY( v[j] == s[j] ); + + for (unsigned i = 0; i < j; ++i) + VERIFY( !(v[j] < v[i]) ); + + for (unsigned i = j; i < v.size(); ++i) + VERIFY( !(v[i] < v[j]) ); + } +} + +void +test01() +{ + for (unsigned size = 4; size <= MAX_SIZE; size <<= 1) + do_test01(size); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/3.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/3.cc new file mode 100644 index 000000000..972428792 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/3.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19}; +const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); +const int logN = 3; // ln(N) rounded up +const int P = 7; + +// comparison predicate for stable_sort: order by rightmost digit +struct CompLast +{ + bool + operator()(const int x, const int y) + { return x % 10 < y % 10; } +}; + +// This functor has the equivalent functionality of std::geater<>, +// but there is no dependency on and it also tracks the +// number of invocations since creation. +class Gt +{ +public: + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + + bool + operator()(const int& x, const int& y) + { + ++itsCount; + return x > y; + } + +private: + static int itsCount; +}; + +int Gt::itsCount = 0; + +// 25.3.2 nth_element() +void +test05() +{ + using std::nth_element; + + int s1[N]; + std::copy(B, B + N, s1); + VERIFY(std::equal(s1, s1 + N, B)); + + int* pn = s1 + (N / 2) - 1; + nth_element(s1, pn, s1 + N); + for (const int* i = pn; i < s1 + N; ++i) VERIFY(!(*i < *pn)); + + CompLast pred; + nth_element(s1, pn, s1 + N, pred); + for (const int* i = pn; i < s1 + N; ++i) VERIFY(!pred(*i, *pn)); +} + +int +main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc new file mode 100644 index 000000000..9f8c3b399 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.2 [lib.alg.nth.element] + +// { dg-do compile } + +#include +#include + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper& s) +{ std::nth_element(s, s, s); } + +void +test2(random_access_iterator_wrapper& x) +{ std::nth_element(x, x, x, predicate); } + diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/moveable.cc new file mode 100644 index 000000000..481f52e52 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/moveable.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.2 [lib.alg.nth.element] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::nth_element; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + + int intarray[] = {6, 5, 4, 3, 2, 1, 0}; + rvalstruct array[7]; + std::copy(intarray, intarray + 7, array); + Container con(array, array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY( array[i].val < 3 ); + for(int i = 4; i < 7; ++i) + VERIFY( array[i].val > 3 ); + for(int i = 0; i < 7; ++i) + VERIFY( array[i].valid ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + int intarray[] = {0, 6, 1, 5, 2, 4, 3}; + rvalstruct array[7]; + std::copy(intarray, intarray + 7, array); + Container con(array,array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY( array[i].val < 3 ); + for(int i = 4; i < 7; ++i) + VERIFY( array[i].val > 3 ); + for(int i = 0; i < 7; ++i) + VERIFY( array[i].valid ); +} + +bool +are_less(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test3() +{ + bool test __attribute__((unused)) = true; + + int intarray[] = {0, 6, 1, 5, 2, 4, 3}; + rvalstruct array[7]; + std::copy(intarray, intarray + 7, array); + Container con(array,array + 7); + nth_element(con.begin(), con.it(3), con.end(), are_less); + for(int i = 0; i < 3; ++i) + VERIFY( array[i].val < 3 ); + for(int i = 4; i < 7; ++i) + VERIFY( array[i].val > 3 ); + for(int i = 0; i < 7; ++i) + VERIFY( array[i].valid ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..28a9f935c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void nth_element(iterator_type, iterator_type, iterator_type); + template void nth_element(iterator_type, iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..b9713eef4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void nth_element(iterator_type, iterator_type, iterator_type); + template void nth_element(iterator_type, iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc new file mode 100644 index 000000000..f13938b8c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.3 [lib.partial.sort] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::partial_sort; + +typedef test_container Container; + +void +test1() +{ + int array[]={2,1,0}; + Container con1(array, array + 2); + Container con2(array, array); + partial_sort(con2.begin(), con2.begin(), con2.end()); + partial_sort(con1.begin(), con1.begin(), con1.end()); + partial_sort(con1.begin(), con1.end(), con1.end()); +} + +void +test2() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2); +} + +void +test3() +{ + int array[] = {0, 6, 1, 5, 2, 4, 3}; + Container con(array,array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/2.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/2.cc new file mode 100644 index 000000000..afb07ddce --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/2.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19}; +const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); +const int logN = 3; // ln(N) rounded up +const int P = 7; + +// comparison predicate for stable_sort: order by rightmost digit +struct CompLast +{ + bool + operator()(const int x, const int y) + { return x % 10 < y % 10; } +}; + +// This functor has the equivalent functionality of std::geater<>, +// but there is no dependency on and it also tracks the +// number of invocations since creation. +class Gt +{ +public: + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + + bool + operator()(const int& x, const int& y) + { + ++itsCount; + return x > y; + } + +private: + static int itsCount; +}; + +int Gt::itsCount = 0; + +// 25.3.1.3 partial_sort() +void +test03() +{ + int s1[N]; + std::copy(B, B + N, s1); + VERIFY(std::equal(s1, s1 + N, B)); + + std::partial_sort(s1, s1 + P, s1 + N); + VERIFY(std::equal(s1, s1 + P, A)); + + Gt gt; + gt.reset(); + std::partial_sort(s1, s1 + P, s1 + N, gt); + VERIFY(std::equal(s1, s1 + P, C)); +} + +int +main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_compare_by_value.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_compare_by_value.cc new file mode 100644 index 000000000..e6bb20f6b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_compare_by_value.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.3 [lib.partial.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; + +typedef __gnu_test::rvalstruct_compare_by_value V; +typedef test_container Container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::partial_sort(con.begin(), con.begin() + 10, con.end()); + VERIFY( s1[0].ok ); + for(int i = 1; i < 10; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); + for(int i = 10; i < N; ++i) + VERIFY( s1[i].val > s1[9].val && s1[i].ok ); + +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::partial_sort(con.begin(), con.begin() + 10, con.end(), + __gnu_test::order); + VERIFY( s1[0].ok ); + for(int i = 1; i < 10; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); + for(int i = 10; i < N; ++i) + VERIFY( s1[i].val > s1[9].val && s1[i].ok ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + V vvs[] = { 2, 0 }; + std::partial_sort(vvs, vvs + 2, vvs + 2); + VERIFY( vvs[0].ok && vvs[0].val == 0 ); + VERIFY( vvs[1].ok && vvs[1].val == 2 ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc new file mode 100644 index 000000000..ff073fc44 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.3 [lib.partial.sort] + +// { dg-do compile } + +#include +#include + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper& s) +{ + std::partial_sort(s, s, s); +} + +void +test2(random_access_iterator_wrapper& x) +{ + std::partial_sort(x, x, x, predicate); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/moveable.cc new file mode 100644 index 000000000..ca5bd7a10 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/moveable.cc @@ -0,0 +1,96 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.3 [lib.partial.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::partial_sort; + +typedef test_container Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + + int intarray[] = {6, 5, 4, 3, 2, 1, 0}; + rvalstruct array[7]; + std::copy(intarray, intarray + 7, array); + Container con(array, array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY( array[0].val == 0 && array[1].val == 1 && array[2].val == 2 ); + for(int i = 0; i < 7; ++i) + VERIFY( array[i].valid ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + int intarray[] = {0, 6, 1, 5, 2, 4, 3}; + rvalstruct array[7]; + std::copy(intarray, intarray + 7, array); + Container con(array,array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY( array[0].val == 0 && array[1].val == 1 && array[2].val == 2 ); + for(int i = 0; i < 7; ++i) + VERIFY( array[i].valid ); +} + +bool are_less(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test3() +{ + bool test __attribute__((unused)) = true; + + int intarray[] = {0, 6, 1, 5, 2, 4, 3}; + rvalstruct array[7]; + std::copy(intarray, intarray + 7, array); + Container con(array,array + 7); + partial_sort(con.begin(), con.it(3), con.end(), are_less); + VERIFY( array[0].val == 0 && array[1].val == 1 && array[2].val == 2 ); + for(int i = 0; i < 7; ++i) + VERIFY( array[i].valid ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ef828ec4a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void partial_sort(iterator_type, iterator_type, iterator_type); + template void partial_sort(iterator_type, iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..8a166c5f5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void partial_sort(iterator_type, iterator_type, iterator_type); + template void partial_sort(iterator_type, iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc new file mode 100644 index 000000000..53216bda2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc @@ -0,0 +1,88 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.4 [lib.partial.sort.copy] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::input_iterator_wrapper; +using std::partial_sort_copy; + +typedef test_container Rcontainer; +typedef test_container Icontainer; + +void +test1() +{ + int array[]={2,1,0}; + Rcontainer rcon1(array, array); + Rcontainer rcon2(array, array + 2); + Icontainer icon1(array, array); + Icontainer icon2(array, array + 2); + partial_sort_copy(icon1.begin(), icon1.end(), rcon1.begin(), rcon1.end()); + partial_sort_copy(icon1.begin(), icon1.end(), rcon2.begin(), rcon2.end()); + partial_sort_copy(icon2.begin(), icon2.end(), rcon1.begin(), rcon1.end()); + partial_sort_copy(icon2.begin(), icon2.end(), rcon2.begin(), rcon2.end()); +} + +void +test2() +{ + int array1[] = {4, 3, 2, 1, 0}; + int array2[5]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 5); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 && + array2[3] == 3 && array2[4] == 4); +} + +void +test3() +{ + int array1[] = {4, 0, 1, 3, 2}; + int array2[5]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 2); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +void +test4() +{ + int array1[] = {4, 1, 3, 2, 0}; + int array2[20]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 20); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 && + array2[3] == 3 && array2[4] == 4); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/2.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/2.cc new file mode 100644 index 000000000..5498db849 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/2.cc @@ -0,0 +1,91 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19}; +const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); +const int logN = 3; // ln(N) rounded up +const int P = 7; + +// comparison predicate for stable_sort: order by rightmost digit +struct CompLast +{ + bool + operator()(const int x, const int y) + { return x % 10 < y % 10; } +}; + +// This functor has the equivalent functionality of std::geater<>, +// but there is no dependency on and it also tracks the +// number of invocations since creation. +class Gt +{ +public: + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + + bool + operator()(const int& x, const int& y) + { + ++itsCount; + return x > y; + } + +private: + static int itsCount; +}; + +int Gt::itsCount = 0; + + +// 25.3.1.4 partial_sort_copy() +void +test04() +{ + using std::partial_sort_copy; + + int s1[N]; + std::copy(B, B + N, s1); + VERIFY(std::equal(s1, s1 + N, B)); + + int s2[2*N]; + + partial_sort_copy(s1, s1 + N, s2, s2 + P); + VERIFY(std::equal(s2, s2 + P, A)); + + Gt gt; + gt.reset(); + partial_sort_copy(s1, s1 + N, s2, s2 + P, gt); + VERIFY(std::equal(s2, s2 + P, C)); + + VERIFY(std::equal(s2, partial_sort_copy(s1, s1 + N, s2, s2 + 2*N), A)); +} + +int +main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc new file mode 100644 index 000000000..3b5416bf2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.4 [lib.partial.sort.copy] + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; + +struct S1 { }; +struct S2 +{ + S2(const S1&) {} + S2() {} +}; + +bool +operator<(const S1&, const S1&) +{return true;} + +bool +operator<(const S2&, const S2&) +{return true;} + +struct X1 { }; +struct X2 +{ + X2(const X1&) {} + X2() {} +}; + +struct predicate +{ + bool + operator()(const X1&, const X1&) + {return true;} + + bool + operator()(const X2&, const X2&) + {return true;} +}; + +random_access_iterator_wrapper +test1(input_iterator_wrapper& s1, random_access_iterator_wrapper& s2) +{ return std::partial_sort_copy(s1, s1, s2, s2); } + +random_access_iterator_wrapper +test2(input_iterator_wrapper& x1, random_access_iterator_wrapper& x2) +{ return std::partial_sort_copy(x1, x1, x2, x2, predicate()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..addc0b0e0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type partial_sort_copy(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type partial_sort_copy(iterator_type, iterator_type, + iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..ae37673a6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type partial_sort_copy(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type partial_sort_copy(iterator_type, iterator_type, + iterator_type, iterator_type, + compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition/1.cc b/libstdc++-v3/testsuite/25_algorithms/partition/1.cc new file mode 100644 index 000000000..bbad940a4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N = sizeof(A) / sizeof(int); + +struct Pred +{ + bool + operator()(const int& x) const + { return (x % 2) == 0; } +}; + +// 25.2.12 partition() +void +test01() +{ + using std::partition; + + int s1[N]; + std::copy(A, A + N, s1); + + Pred pred; + int* m = partition(s1, s1 + N, pred); + for (const int* i = s1; i < m; ++i) VERIFY(pred(*i)); + for (const int* i = m; i < s1 + N; ++i) VERIFY(!pred(*i)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/partition/moveable.cc new file mode 100644 index 000000000..7e742f47b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition/moveable.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [lib.alg.partitions] Partitions. + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Fcontainer; +typedef test_container Bcontainer; + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N = sizeof(A) / sizeof(int); + +struct Pred +{ + bool + operator()(const rvalstruct& x) const + { return (x.val % 2) == 0; } +}; + +// 25.2.12 partition() +void +test01() +{ + using std::partition; + + rvalstruct farray[N]; + rvalstruct barray[N]; + + std::copy(A, A + N, farray); + std::copy(A, A + N, barray); + + Fcontainer fcon(farray, farray + N); + Bcontainer bcon(barray, barray + N); + + Pred pred; + + VERIFY(partition(fcon.begin(), fcon.end(), pred).ptr - farray == N/2); + for (const rvalstruct* i = farray; i < farray+N/2; ++i) + VERIFY(pred(*i)); + + for (const rvalstruct* i = farray+N/2; i < farray + N; ++i) + VERIFY(!pred(*i)); + + VERIFY(partition(bcon.begin(), bcon.end(), pred).ptr - barray == N/2); + + for (const rvalstruct* i = barray; i < barray+N/2; ++i) + VERIFY(pred(*i)); + for (const rvalstruct* i = barray+N/2; i < barray + N; ++i) + VERIFY(!pred(*i)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..d951ce692 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type partition(iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..eefcf89e9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type partition(iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/partition_copy/1.cc new file mode 100644 index 000000000..2a0e2db9f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_copy/1.cc @@ -0,0 +1,106 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-26 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container Icontainer; +typedef test_container Ocontainer; +int array[] = {0, 5, 2, 1, 3, 4}; + +bool +pred(int i) +{ return i > 2; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + int true_out[1] = { -1 }; + int false_out[1] = { -1 }; + Icontainer in_con(array, array); + Ocontainer true_out_con(true_out, true_out); + Ocontainer false_out_con(false_out, false_out); + + std::pair, output_iterator_wrapper > res = + std::partition_copy(in_con.begin(), in_con.end(), + true_out_con.begin(), false_out_con.begin(), pred); + + VERIFY( res.first.ptr == true_out ); + VERIFY( res.second.ptr == false_out ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + int true_out[1] = { -1 }; + int false_out[1] = { -1 }; + Icontainer in_con(array, array + 2); + Ocontainer true_out_con(true_out, true_out + 1); + Ocontainer false_out_con(false_out, false_out + 1); + + std::pair, output_iterator_wrapper > res = + std::partition_copy(in_con.begin(), in_con.end(), + true_out_con.begin(), false_out_con.begin(), pred); + + VERIFY( res.first.ptr == true_out + 1 ); + VERIFY( res.second.ptr == false_out + 1 ); + VERIFY( true_out[0] == 5 ); + VERIFY( false_out[0] == 0 ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + int true_out[3] = { -1, -1, -1 }; + int false_out[3] = { -1, -1, -1 }; + Icontainer in_con(array, array + 6); + Ocontainer true_out_con(true_out, true_out + 3); + Ocontainer false_out_con(false_out, false_out + 3); + + std::pair, output_iterator_wrapper > res = + std::partition_copy(in_con.begin(), in_con.end(), + true_out_con.begin(), false_out_con.begin(), pred); + + VERIFY( res.first.ptr == true_out + 3 ); + VERIFY( res.second.ptr == false_out + 3 ); + VERIFY( true_out[0] == 5 && true_out[1] == 3 && true_out[2] == 4 ); + VERIFY( false_out[0] == 0 && false_out[1] == 2 && false_out[2] == 1 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partition_copy/check_type.cc new file mode 100644 index 000000000..3e952ac5d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_copy/check_type.cc @@ -0,0 +1,70 @@ +// 2008-06-26 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Z1 +{ + Z1& + operator=(const X&) + { return *this; } +}; + +struct Z2 +{ + Z2& + operator=(const X&) + { return *this; } +}; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +std::pair, output_iterator_wrapper > +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& true_output, + output_iterator_wrapper& false_output) +{ return std::partition_copy(begin, end, true_output, false_output, + pred_function); } + +std::pair, output_iterator_wrapper > +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& true_output, + output_iterator_wrapper& false_output) +{ return std::partition_copy(begin, end, true_output, false_output, + pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..a2aca1050 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-26 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template pair + partition_copy(iterator_type, iterator_type, + iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..3af8b5bf4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-26 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template pair + partition_copy(iterator_type, iterator_type, + iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_point/1.cc b/libstdc++-v3/testsuite/25_algorithms/partition_point/1.cc new file mode 100644 index 000000000..e6bee14e1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_point/1.cc @@ -0,0 +1,85 @@ +// { dg-options "-std=gnu++0x" } + +// 2008-06-28 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 1, 1, 1, 1}; + +bool +predicate(const int& i) +{ return i == 0; } + +void +test1() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array); + + forward_iterator_wrapper mid = + std::partition_point(con.begin(), con.end(), predicate); + + VERIFY( std::all_of(con.begin(), mid, predicate) ); + VERIFY( std::none_of(mid, con.end(), predicate) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 1); + + forward_iterator_wrapper mid = + std::partition_point(con.begin(), con.end(), predicate); + + VERIFY( std::all_of(con.begin(), mid, predicate) ); + VERIFY( std::none_of(mid, con.end(), predicate) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + Container con(array, array + 6); + + forward_iterator_wrapper mid = + std::partition_point(con.begin(), con.end(), predicate); + + VERIFY( std::all_of(con.begin(), mid, predicate) ); + VERIFY( std::none_of(mid, con.end(), predicate) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_point/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partition_point/check_type.cc new file mode 100644 index 000000000..5434e10c2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_point/check_type.cc @@ -0,0 +1,49 @@ +// 2008-06-28 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +#include +#include + +struct X { }; + +using __gnu_test::forward_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +forward_iterator_wrapper +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end) +{ return std::partition_point(begin, end, pred_function); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end) +{ return std::partition_point(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..0ec0a68ec --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-28 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type partition_point(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2982f2887 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partition_point/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2008-06-28 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type partition_point(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..274c5f773 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void pop_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..384e8b4d0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/pop_heap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void pop_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc new file mode 100644 index 000000000..b6c023b2d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc @@ -0,0 +1,83 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.9 [lib.alg.permutation.generators] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::prev_permutation; + +typedef test_container Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(!prev_permutation(con.begin(), con.end())); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(!prev_permutation(con.begin(), con.end())); +} + +void +test3() +{ + int array[] = {3, 0}; + Container con(array, array + 2); + VERIFY(prev_permutation(con.begin(), con.end())); + VERIFY(array[0] == 0 && array[1] == 3); + VERIFY(!prev_permutation(con.begin(), con.end())); + VERIFY(array[0] == 3 && array[1] == 0); +} + +void +test4() +{ + int array[6] = {5, 4, 3, 2, 1, 0}; + Container con(array, array + 6); + for(int i = 0 ; i < 719; ++i) + { + int temp_array[6]; + std::copy(array, array + 6, temp_array); + VERIFY(prev_permutation(array, array + 6)); + VERIFY(std::lexicographical_compare(array, array + 6, + temp_array, temp_array + 6)); + } + VERIFY(!prev_permutation(array,array + 6)); + for(int i = 0; i < 6; ++i) + VERIFY(array[i] == 5 - i); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc new file mode 100644 index 000000000..5d6bdbfd1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.9 [lib.alg.permutation.generators] + +// { dg-do compile } + +#include +#include + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(bidirectional_iterator_wrapper& s) +{ return std::prev_permutation(s,s); } + +bool +test2(bidirectional_iterator_wrapper& x) +{ return std::prev_permutation(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/moveable.cc new file mode 100644 index 000000000..5570239b0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/moveable.cc @@ -0,0 +1,125 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.9 [lib.alg.permutation.generators] + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::prev_permutation; + +typedef test_container Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + rvalstruct array[] = {0}; + Container con(array, array); + VERIFY( !prev_permutation(con.begin(), con.end()) ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + + rvalstruct array[] = {0}; + Container con(array, array + 1); + VERIFY( !prev_permutation(con.begin(), con.end()) ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + + rvalstruct array[] = {3, 0}; + Container con(array, array + 2); + VERIFY( prev_permutation(con.begin(), con.end()) ); + VERIFY( array[0] == 0 && array[1] == 3 ); + VERIFY( !prev_permutation(con.begin(), con.end()) ); + VERIFY( array[0] == 3 && array[1] == 0 ); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + + int array[6] = {5, 4, 3, 2, 1, 0}; + for(int i = 0 ; i < 719; ++i) + { + rvalstruct temp_array[6]; + std::copy(array, array + 6, temp_array); + Container con(temp_array, temp_array + 6); + VERIFY( prev_permutation(array, array + 6) ); + VERIFY( !std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6) ); + } + VERIFY( !prev_permutation(array,array + 6)) ; + for(int i = 0; i < 6; ++i) + VERIFY( array[i] == (5 - i) ); +} + +bool +are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +void +test5() +{ + bool test __attribute__((unused)) = true; + + int array[6] = {5, 4, 3, 2, 1, 0}; + for(int i = 0 ; i < 719; ++i) + { + rvalstruct temp_array[6]; + std::copy(array, array + 6, temp_array); + Container con(temp_array, temp_array + 6); + VERIFY( prev_permutation(array, array + 6, are_ordered) ); + VERIFY( !std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6, are_ordered) ); + } + VERIFY( !prev_permutation(array,array + 6, are_ordered) ); + for(int i = 0; i < 6; ++i) + VERIFY( array[i] == (5 - i) ); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..9764d6f60 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool prev_permutation(iterator_type, iterator_type); + template bool prev_permutation(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..d799b3983 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template bool prev_permutation(iterator_type, iterator_type); + template bool prev_permutation(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..779aebefb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void push_heap(iterator_type, iterator_type); + template void push_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..27950b69c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/push_heap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void push_heap(iterator_type, iterator_type); + template void push_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc new file mode 100644 index 000000000..cd92398a3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/1.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.11 random_shuffle() + +#include +#include + +bool test __attribute__((unused)) = true; + +const int N = 200000; +int A[N], s1[N]; + +#if _GLIBCXX_PARALLEL +#define TAG , __gnu_parallel::sequential_tag() +#else +#define TAG +#endif + +void fill_ascending() +{ + for (int i = 0; i < N; ++i) + A[i] = i; +} + +void +test01() +{ + fill_ascending(); +#if _GLIBCXX_PARALLEL + for (int num_threads = 1; num_threads <= 2; ++num_threads) + { + omp_set_num_threads(num_threads); +#endif + std::copy(A, A + N, s1); + VERIFY(std::equal(s1, s1 + N, A TAG)); + + std::random_shuffle(s1, s1 + N); + // the chance that random_shuffle leaves the order as is by coincidence + // is negligible, so we expect it to be permuted + VERIFY(!std::equal(s1, s1 + N, A TAG)); + + std::sort(s1, s1 + N TAG); + VERIFY(std::equal(s1, s1 + N, A TAG)); +#if _GLIBCXX_PARALLEL + } +#endif +} + +int +main() +{ +#if _GLIBCXX_PARALLEL + __gnu_parallel::_Settings gpms = __gnu_parallel::_Settings::get(); + gpms.algorithm_strategy = __gnu_parallel::force_parallel; + __gnu_parallel::_Settings::set(gpms); +#endif + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc new file mode 100644 index 000000000..cbf170be3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc @@ -0,0 +1,89 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.11 random_shuffle() + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +const int N = 200000; +int A[N]; + +void fill_ascending() +{ + for (int i = 0; i < N; ++i) + A[i] = i; +} + +void +test01() +{ + bool test __attribute__((unused)) = true; + + fill_ascending(); + rvalstruct rv[N]; + std::copy(A, A + N, rv); + Container con(rv, rv + N); + std::random_shuffle(con.begin(), con.end()); + + // The chance that random_shuffle leaves the order as is by coincidence + // is negligible, so we expect it to be permuted + VERIFY( !std::equal(rv, rv + N, A) ); + + std::sort(con.begin(), con.end()); + VERIFY( std::equal(rv, rv + N, A) ); +} + +int random_generator(int) +{ return 0; } + +void +test02() +{ + bool test __attribute__((unused)) = true; + + fill_ascending(); + rvalstruct rv[10] = {1,2,3,4,5,6,7,8,9,10}; + int result[10] = {10,1,2,3,4,5,6,7,8,9}; + Container con(rv, rv + 10); + std::random_shuffle(con.begin(), con.end(), random_generator); + // The above answer was generated by hand. It is not required by the standard, + // but is produced by the current algorithm. + VERIFY( std::equal(rv, rv + 10, result) ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..82fd11d31 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function generator_type; + + template void random_shuffle(iterator_type, iterator_type); + template void random_shuffle(iterator_type, iterator_type, + generator_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..f1b59b38c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function generator_type; + + template void random_shuffle(iterator_type, iterator_type); + template void random_shuffle(iterator_type, iterator_type, + generator_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/1.cc b/libstdc++-v3/testsuite/25_algorithms/remove/1.cc new file mode 100644 index 000000000..381cd7554 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/1.cc @@ -0,0 +1,62 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 remove + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; + +void +test1() +{ + int array[1]; + Container con(array, array); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array); +} + +void +test2() +{ + int array[] = {1}; + Container con(array, array + 1); + VERIFY(std::remove(con.begin(), con.end(), 0).ptr == array + 1); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array); +} + +void +test3() +{ + int array[] = {0, 1, 0, 1, 0, 0, 1, 1}; + Container con(array, array + 8); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc new file mode 100644 index 000000000..27b9c2274 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.7 Remove + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, const Y& val) +{ return std::remove(begin, end, val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/remove/moveable.cc new file mode 100644 index 000000000..94ceded74 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/moveable.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 remove + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +void +test1() +{ + int intarray[] = {1}; + rvalstruct array[1]; + std::copy(intarray, intarray + 1, array); + Container con(array, array + 1); + rvalstruct remove_val0(0); + rvalstruct remove_val1(1); + VERIFY(std::remove(con.begin(), con.end(), remove_val0).ptr == array + 1); + VERIFY(std::remove(con.begin(), con.end(), remove_val1).ptr == array); +} + +void +test2() +{ + int intarray[] = {0, 1, 0, 1, 0, 0, 1, 1}; + rvalstruct array[8]; + std::copy(intarray, intarray + 8, array); + Container con(array, array + 8); + rvalstruct remove_val(1); + VERIFY(std::remove(con.begin(), con.end(), remove_val).ptr == array + 4); + VERIFY(array[0].val == 0 && array[1].val == 0 && array[2].val == 0 && + array[3].val == 0); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..49f9b39ec --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type remove(iterator_type, iterator_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..951dea018 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type remove(iterator_type, iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..d447766b8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type remove_copy(iterator_type, iterator_type, + iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..5db385b31 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type remove_copy(iterator_type, iterator_type, + iterator_type, const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc new file mode 100644 index 000000000..3c4969641 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/check_type.cc @@ -0,0 +1,58 @@ +// 2008-06-25 Paolo Carlini + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Z +{ + Z& + operator=(const X&) + { return *this; } +}; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +output_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::remove_copy_if(begin, end, output, pred_function); } + +output_iterator_wrapper +test2(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output) +{ return std::remove_copy_if(begin, end, output, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..bc6f586ea --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type remove_copy_if(iterator_type, iterator_type, + iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..e5f760993 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_copy_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type remove_copy_if(iterator_type, iterator_type, + iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc new file mode 100644 index 000000000..cc1426a16 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 remove + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; + +bool equal1(int val) { return val == 1; } +bool equal0(int val) { return val == 0; } + +void +test1() +{ + int array[1]; + Container con(array, array); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test2() +{ + int array[] = {1}; + Container con(array, array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal0).ptr == array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test3() +{ + int array[] = {0, 1, 0, 1, 0, 0, 1, 1}; + Container con(array, array + 8); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc new file mode 100644 index 000000000..206b78e8a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.7 Remove_if + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +pred_fn(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) const + { return true; } +}; + +forward_iterator_wrapper +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end) +{ return std::remove_if(begin, end, pred_fn); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end) +{ return std::remove_if(begin, end, pred_obj()); } + diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc new file mode 100644 index 000000000..bb447d055 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/moveable.cc @@ -0,0 +1,71 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 remove + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +bool equal1(rvalstruct& in) { return in.val == 1; } +bool equal0(rvalstruct& in) { return in.val == 0; } + +void +test1() +{ + int intarray[] = {1}; + rvalstruct array[1]; + std::copy(intarray, intarray + 1, array); + Container con(array, array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal0).ptr == array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test2() +{ + int intarray[] = {0, 1, 0, 1, 0, 0, 1, 1}; + rvalstruct array[8]; + std::copy(intarray, intarray + 8, array); + Container con(array, array + 8); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..7033d271f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type remove_if(iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..fab241a91 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type remove_if(iterator_type, iterator_type, + predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace/1.cc new file mode 100644 index 000000000..71036e2c7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/1.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + std::replace(con.begin(), con.end(), 1, 1); +} + +void +test2() +{ + Container con(array, array + 1); + std::replace(con.begin(), con.end(), 0, 1); + VERIFY(array[0] == 1); +} + +void +test3() +{ + Container con(array, array + 6); + std::replace(con.begin(), con.end(), 1, 2); + VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 && + array[3] == 2 && array[4] == 0 && array[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc new file mode 100644 index 000000000..9832dead8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 Replace + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +operator==(const X&, const X&) +{ return true; } + +void +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, const X& old_val, + const X& new_val) +{ return std::replace(begin, end, old_val, new_val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..d64d18dd2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template void replace(iterator_type, iterator_type, const value_type&, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2387ac8a9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template void replace(iterator_type, iterator_type, const value_type&, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc new file mode 100644 index 000000000..722f2462e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace_copy + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container Icontainer; +typedef test_container Ocontainer; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + int out[1]; + Icontainer in_con(array, array); + Ocontainer out_con(out, out); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 1, 1).ptr == out); +} + +void +test2() +{ + int out[1]; + Icontainer in_con(array, array + 1); + Ocontainer out_con(out, out + 1); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 0, 1).ptr == out + 1); + VERIFY(out[0] == 1); +} + +void +test3() +{ + int out[6]; + Icontainer in_con(array, array + 6); + Ocontainer out_con(out, out + 6); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 1, 2).ptr == out + 6); + VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 && + out[3] == 2 && out[4] == 0 && out[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc new file mode 100644 index 000000000..aa7819634 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace_copy + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Y { }; + +struct Z +{ + Z& + operator=(const X&) + { return *this; } + + Z& + operator=(const Y&) + { return *this; } +}; + +bool +operator==(const X&, const Y&) +{ return true; } + +output_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output, + const Y& old_val, const Y& new_val) +{ + return std::replace_copy(begin, end, output, old_val, + new_val); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..9bbc7d1ef --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type replace_copy(iterator_type, iterator_type, + iterator_type, const value_type&, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..df007c536 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type replace_copy(iterator_type, iterator_type, + iterator_type, const value_type&, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc new file mode 100644 index 000000000..1010556df --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace_copy_if + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container Icontainer; +typedef test_container Ocontainer; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +pred(int i) +{ return i == 1; } + +void +test1() +{ + int out[1]; + Icontainer in_con(array, array); + Ocontainer out_con(out, out); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 1).ptr == out); +} + +void +test2() +{ + int out[1]; + Icontainer in_con(array, array + 1); + Ocontainer out_con(out, out + 1); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 2).ptr == out + 1); + VERIFY(out[0] == 0); +} + +void +test3() +{ + int out[6]; + Icontainer in_con(array, array + 6); + Ocontainer out_con(out, out + 6); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 2).ptr == out + 6); + VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 && + out[3] == 2 && out[4] == 0 && out[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc new file mode 100644 index 000000000..4cb9455e0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace_copy_if + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Y { }; + +struct Z +{ + Z& + operator=(const X&) + { return *this; } + + Z& + operator=(const Y&) + { return *this; } +}; + +bool +predicate(const X&) +{ return true; } + +output_iterator_wrapper +test1(input_iterator_wrapper& begin, + input_iterator_wrapper& end, + output_iterator_wrapper& output, + const Y& new_val) +{ + return std::replace_copy_if(begin, end, output, predicate, + new_val); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..50d5ff2c3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type replace_copy_if(iterator_type, iterator_type, + iterator_type, predicate_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..077a905f6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type replace_copy_if(iterator_type, iterator_type, + iterator_type, predicate_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc new file mode 100644 index 000000000..ebace9324 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace_if + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; +int array[] = {1, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + std::replace_if(con.begin(), con.end(), predicate, 1); +} + +void +test2() +{ + Container con(array, array + 1); + std::replace_if(con.begin(), con.end(), predicate, 2); + VERIFY(array[0] == 2); +} + +void +test3() +{ + Container con(array, array + 6); + std::replace_if(con.begin(), con.end(), predicate, 3); + VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 && + array[3] == 3 && array[4] == 0 && array[5] == 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc new file mode 100644 index 000000000..258033a22 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 replace_if + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +pred_fn(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + + +void +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, const X& new_val) +{ return std::replace_if(begin, end, pred_fn, new_val); } + +void +test2(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, const X& new_val) +{ return std::replace_if(begin, end, pred_obj(), new_val); } + + diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..9d722e97d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template void replace_if(iterator_type, iterator_type, predicate_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..98a8e8210 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template void replace_if(iterator_type, iterator_type, predicate_type, + const value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/reverse/moveable.cc new file mode 100644 index 000000000..9a871db5f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/reverse/moveable.cc @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.9 Reverse + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include + +using __gnu_test::bidirectional_iterator_wrapper; + +class X +{ + X(); + X(const X&); + void operator=(const X&); +}; + +void +swap(X&, X&) { } + +void +test1(bidirectional_iterator_wrapper& begin, + bidirectional_iterator_wrapper& end) +{ std::reverse(begin, end); } diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..de411e645 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template void reverse(iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..f0e6c951e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/reverse/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template void reverse(iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/2.cc new file mode 100644 index 000000000..6c119efdb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type reverse_copy(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/pod.cc new file mode 100644 index 000000000..908db47eb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/reverse_copy/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type reverse_copy(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc new file mode 100644 index 000000000..eac096c42 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc @@ -0,0 +1,125 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.10 rotate + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; + +typedef test_container Fcontainer; +typedef test_container Bcontainer; +typedef test_container Rcontainer; + + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array[]={1}; + Fcontainer fcon(array, array); + Bcontainer bcon(array, array); + Rcontainer rcon(array, array); + std::rotate(fcon.begin(), fcon.begin(), fcon.end()); + std::rotate(bcon.begin(), bcon.begin(), bcon.end()); + std::rotate(rcon.begin(), rcon.begin(), rcon.end()); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array[] = {1}; + Fcontainer fcon(array, array + 1); + Bcontainer bcon(array, array + 1); + Rcontainer rcon(array, array + 1); + std::rotate(fcon.begin(), fcon.begin(), fcon.end()); + std::rotate(bcon.begin(), bcon.begin(), bcon.end()); + std::rotate(rcon.begin(), rcon.begin(), rcon.end()); + std::rotate(fcon.begin(), fcon.end(), fcon.end()); + std::rotate(bcon.begin(), bcon.end(), bcon.end()); + std::rotate(rcon.begin(), rcon.end(), rcon.end()); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4, 5}; + Fcontainer fcon(array, array + 5); + Bcontainer bcon(array, array + 5); + Rcontainer rcon(array, array + 5); + std::rotate(fcon.begin(), fcon.it(2), fcon.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 5 && + array[3] == 1 && array[4] == 2); + std::rotate(bcon.begin(), bcon.it(2), bcon.end()); + VERIFY(array[0] == 5 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4); + std::rotate(rcon.begin(), rcon.it(2), rcon.end()); + VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 && + array[3] == 5 && array[4] == 1); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4}; + Fcontainer fcon(array, array + 4); + Bcontainer bcon(array, array + 4); + Rcontainer rcon(array, array + 4); + + std::rotate(fcon.begin(), fcon.it(3), fcon.end()); + VERIFY(array[0] == 4 && array[1] == 1 && array[2] == 2 && + array[3] == 3); + + std::rotate(bcon.begin(), bcon.it(3), bcon.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 && + array[3] == 2); + + std::rotate(rcon.begin(), rcon.it(3), rcon.end()); + VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 && + array[3] == 1); + +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4}; + Rcontainer con(array, array + 4); + std::rotate(con.begin(), con.it(2), con.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 && + array[3] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc new file mode 100644 index 000000000..ca3a05da0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.10 Rotate + +// { dg-do compile } + +#include +#include + +struct X { }; + +bool operator<(X,X) { return true;} + +void +test1(__gnu_test::forward_iterator_wrapper& begin, + __gnu_test::forward_iterator_wrapper& middle, + __gnu_test::forward_iterator_wrapper& end) +{ return std::rotate(begin,middle,end); } + +void +test1(__gnu_test::bidirectional_iterator_wrapper& begin, + __gnu_test::bidirectional_iterator_wrapper& middle, + __gnu_test::bidirectional_iterator_wrapper& end) +{ return std::rotate(begin,middle,end); } + +void +test1(__gnu_test::random_access_iterator_wrapper& begin, + __gnu_test::random_access_iterator_wrapper& middle, + __gnu_test::random_access_iterator_wrapper& end) +{ return std::rotate(begin,middle,end); } + + diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable.cc new file mode 100644 index 000000000..ac9e0b309 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.10 rotate + +// Tests rotate when an moveable class is used + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Fcontainer; +typedef test_container Bcontainer; +typedef test_container Rcontainer; + + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int data[] = {1, 2, 3, 4, 5}; + rvalstruct array[5]; + std::copy(data, data + 5, array); + Fcontainer fcon(array, array + 5); + Bcontainer bcon(array, array + 5); + Rcontainer rcon(array, array + 5); + + std::rotate(fcon.begin(), fcon.it(2), fcon.end()); + VERIFY(array[0].val == 3 && array[1].val == 4 && array[2].val == 5 && + array[3].val == 1 && array[4].val == 2); + for(int i=0;i<5;i++) + VERIFY(array[i].valid == true); + + std::rotate(bcon.begin(), bcon.it(2), bcon.end()); + VERIFY(array[0].val == 5 && array[1].val == 1 && array[2].val == 2 && + array[3].val == 3 && array[4].val == 4); + for(int i=0;i<5;i++) + VERIFY(array[i].valid); + + std::rotate(rcon.begin(), rcon.it(2), rcon.end()); + VERIFY(array[0].val == 2 && array[1].val == 3 && array[2].val == 4 && + array[3].val == 5 && array[4].val == 1); + for(int i=0;i<5;i++) + VERIFY(array[i].valid); +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc new file mode 100644 index 000000000..d48d6029a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/moveable2.cc @@ -0,0 +1,79 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.10 rotate + +// Tests rotate when an moveable class is used + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Fcontainer; +typedef test_container Bcontainer; +typedef test_container Rcontainer; + +template + void + test_con(int length, int rotate_pos) + { + bool test __attribute__((unused)) = true; + + rvalstruct array[length]; + for(int i = 0; i < length; ++i) + array[i] = i; + Con con(array, array + length); + std::rotate(con.begin(), con.it(rotate_pos), con.end()); + + if(length != 0) + { + for(int i = 0; i < length; ++i) + VERIFY( array[i].valid && array[i].val == (i + rotate_pos) % length ); + } + } + +void +test01() +{ + for(int i = 0; i < 20; ++i) + { + for(int j = 0; j <= i; ++j) + { + test_con(i, j); + test_con(i, j); + test_con(i, j); + } + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..c6aebab34 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/2.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template void rotate(iterator_type, iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..ab65338a0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template void rotate(iterator_type, iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc new file mode 100644 index 000000000..31bb88e5d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2001, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.?? algorithms, rotate() + +#include +#include +#include + +bool test __attribute__((unused)) = true; + +int A[] = {1, 2, 3, 4, 5, 6, 7}; +int B[] = {2, 3, 4, 5, 6, 7, 1}; +int C[] = {1, 2, 3, 4, 5, 6, 7}; +int D[] = {5, 6, 7, 1, 2, 3, 4}; +const int N = sizeof(A) / sizeof(int); + +/* need a test for a forward iterator -- can't think of one that makes sense */ + +/* biderectional iterator */ +void +test02() +{ + using std::rotate; + typedef std::list Container; + + Container a(A, A + N); + VERIFY(std::equal(a.begin(), a.end(), A)); + + Container::iterator i = a.begin(); + rotate(a.begin(), ++i, a.end()); + VERIFY(std::equal(a.begin(), a.end(), B)); + + i = a.end(); + rotate(a.begin(), --i, a.end()); + VERIFY(std::equal(a.begin(), a.end(), C)); + + i = a.begin(); + std::advance(i, 3); + rotate(a.begin(), ++i, a.end()); + VERIFY(std::equal(a.begin(), a.end(), D)); +} + +/* random iterator */ +void +test03() +{ + using std::rotate; + rotate(A, A + 1, A + N); + VERIFY(std::equal(A, A + N, B)); + + rotate(A, A + N - 1, A + N); + VERIFY(std::equal(A, A + N, C)); + + rotate(A, A + 4, A + N); + VERIFY(std::equal(A, A + N, D)); +} + +int +main() +{ + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..16856ebe8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type rotate_copy(iterator_type, iterator_type, + iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..e2ed47496 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate_copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type rotate_copy(iterator_type, iterator_type, + iterator_type, iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search/1.cc b/libstdc++-v3/testsuite/25_algorithms/search/1.cc new file mode 100644 index 000000000..10a57342c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/1.cc @@ -0,0 +1,162 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.5 [lib.alg.search] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; +using std::search; + +typedef test_container Container; +typedef test_container RAcontainer; +int array1[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}; +int array2[] = {0, 0, 0}; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1); + Container con2(array1, array1 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1); + VERIFY(search(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array1); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1 + 3); + Container con2(array2, array2 + 3); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Container con1(array1 + 3, array1 + 10); + Container con2(array2, array2 + 3); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1 + 10); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1 + 10); + Container con2(array2, array2 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + Container con1(array1 + 6, array1 + 10); + Container con2(array2, array2 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1 + 10); +} + +void +test6() +{ + bool test __attribute__((unused)) = true; + int array3[]={2, 2, 1, 2, 3, 5}; + int array4[]={1, 2, 3, 4}; + Container con1(array3, array3 + 3); + Container con2(array3, array3 + 4); + Container con3(array3, array3 + 5); + Container con4(array3, array3 + 6); + Container endcon(array4, array4 + 4); + VERIFY(search(con1.begin(), con1.end(), endcon.begin(), endcon.end()).ptr + == array3 + 3); + VERIFY(search(con2.begin(), con2.end(), endcon.begin(), endcon.end()).ptr + == array3 + 4); + VERIFY(search(con3.begin(), con3.end(), endcon.begin(), endcon.end()).ptr + == array3 + 5); + VERIFY(search(con4.begin(), con4.end(), endcon.begin(), endcon.end()).ptr + == array3 + 6); +} + +bool +lexstep(int* start, int length) +{ + int i = 0; + int carry = 1; + while(i < length && carry) + { + if(start[i] == 1) + start[i] = 0; + else + { + start[i] = 1; + carry = 0; + } + i++; + } + return !carry; +} + +void test7() +{ + int array1[6]; + int array2[6]; + for(int length1 = 0; length1 < 6; length1++) + { + for(int length2 = 0; length2 < 6; length2++) + { + std::fill_n(array1, length1, 0); + while(lexstep(array1, length1)) + { + std::fill_n(array2, length2, 0); + while(lexstep(array2, length2)) + { + Container con1(array1, array1 + length1); + Container con2(array2, array2 + length2); + RAcontainer rcon1(array1, array1 + length1); + RAcontainer rcon2(array2, array2 + length2); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), + con2.end()).ptr == + search(rcon1.begin(), rcon1.end(), rcon2.begin(), + rcon2.end()).ptr); + } + } + } + } +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc new file mode 100644 index 000000000..417fb4356 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.9 [lib.alg.search] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct T1 { }; +struct T2 { }; + +struct S1 +{ + S1(T1) { } +}; + +struct S2 { + S2(T2) { } +}; + +bool +operator==(const S1&, const S2&) {return true;} + +struct V1 { }; +struct V2 { }; + +struct X1 +{ + X1(V1) { }; +}; + +struct X2 +{ + X2(V2) { }; +}; + +bool +predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& s1, forward_iterator_wrapper& s2) +{ return std::search(s1, s1, s2, s2); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& s1, forward_iterator_wrapper& s2) +{ return std::search(s1, s1, s2, s2); } + +forward_iterator_wrapper +test3(forward_iterator_wrapper& x1, forward_iterator_wrapper& x2) +{ return std::search(x1, x1, x2, x2, predicate); } + +forward_iterator_wrapper +test4(forward_iterator_wrapper& x1, forward_iterator_wrapper& x2) +{ return std::search(x1, x1, x2, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..0633674d2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type search(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type search(iterator_type, iterator_type, + iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..aaf2b1d4a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type search(iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type search(iterator_type, iterator_type, + iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc new file mode 100644 index 000000000..0160b78a5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/11400.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.9 [lib.alg.search] + +// { dg-do compile } + +#include +#include + +struct Integral { operator int() const; }; + +namespace std +{ + template int* search_n (int*, int*, Integral, const int&); + template int* search_n (int*, int*, Integral, const int&, greater); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc new file mode 100644 index 000000000..3f15a4f5b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.1.9 search_n + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, int i, Y& value) +{ return std::search_n(begin, end, i , value); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc new file mode 100644 index 000000000..d7be297f0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc @@ -0,0 +1,111 @@ +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-DTEST_DEPTH=10" { target simulator } } + +// 25 algorithms, search_n + +#include +#include +#include +#include + +#ifndef TEST_DEPTH +#define TEST_DEPTH 14 +#endif + +int array1[11] = {0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0}; +int array2[TEST_DEPTH]; + +bool +pred(int i, int j) +{ + return i == j; +} + +bool +lexstep(int* start, int length) +{ + int i = 0; + int carry = 1; + while(i < length && carry) + { + if(start[i] == 1) + start[i] = 0; + else + { + start[i] = 1; + carry = 0; + } + i++; + } + return !carry; +} + +int main() +{ + using __gnu_test::test_container; + using __gnu_test::random_access_iterator_wrapper; + using __gnu_test::bidirectional_iterator_wrapper; + using __gnu_test::forward_iterator_wrapper; + + using std::search_n; + + test_container con(array1,array1 + 10); + VERIFY(search_n(con.end(), con.end(), 0, 1) == con.end()); + VERIFY(search_n(con.end(), con.end(), 1, 1) == con.end()); + VERIFY(search_n(con.begin(), con.end(), 1, 1).ptr == array1 + 1); + VERIFY(search_n(con.begin(), con.end(), 2, 1).ptr == array1 + 4); + VERIFY(search_n(con.begin(), con.end(), 3, 1).ptr == array1 + 7); + VERIFY(search_n(con.begin(), con.end(), 3, 0) == con.end()); + + // Now do a brute-force comparison of the different types + for(int i = 0; i < TEST_DEPTH; i++) + { + for(int j = 0; j < i; j++) + array2[i] = 0; + do { + for(int j = 0; j < i; j++) + { + test_container + forwardcon(array2, array2 + i); + test_container + randomcon(array2, array2 + i); + test_container + bidircon(array2, array2 + i); + + int* t1 = search_n(forwardcon.begin(), + forwardcon.end(), j, 1).ptr; + int* t2 = search_n(forwardcon.begin(), + forwardcon.end(), j, 1, pred).ptr; + int* t3 = search_n(bidircon.begin(), + bidircon.end(), j, 1).ptr; + int* t4 = search_n(bidircon.begin(), + bidircon.end(), j, 1, pred).ptr; + int* t5 = search_n(randomcon.begin(), + randomcon.end(), j, 1).ptr; + int* t6 = search_n(randomcon.begin(), + randomcon.end(), j, 1, pred).ptr; + VERIFY((t1 == t2) && (t2 == t3) && (t3 == t4) && + (t4 == t5) && (t5 == t6)); + } + } + while(lexstep(array2, i)); + } + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..9d86804eb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/2.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::size_t size_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&); + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..cba6b054c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::size_t size_type; + typedef std::pointer_to_binary_function predicate_type; + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&); + + template iterator_type search_n(iterator_type, iterator_type, + size_type, const value_type&, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc new file mode 100644 index 000000000..f8695e23f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc @@ -0,0 +1,131 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.3 [lib.set.difference] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_difference; + +typedef test_container Icontainer; +typedef test_container Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 3); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 3); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container SIcontainer; +typedef test_container SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -3, -4}; + S array2[] = { 1, 1, 1, 1, 2, 4, 4}; + S array3[9]; + SIcontainer con1(array1, array1 + 7); + SIcontainer con2(array2, array2 + 7); + SOcontainer con3(array3, array3 + 2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 2); + for(int i = 0; i < 2; ++i) + VERIFY(array3[i].j == 0); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/35541.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/35541.cc new file mode 100644 index 000000000..b78f3260d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/35541.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/35541 + +#include +#include +#include + +void test01() +{ + std::set > mFactors; + std::set > secondFactor; + std::set_difference(mFactors.begin(), mFactors.end(), + mFactors.begin(), mFactors.end(), + std::insert_iterator > > + (secondFactor, secondFactor.end())); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc new file mode 100644 index 000000000..8f0f61c0e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.4 [lib.set.difference] + +// { dg-do compile } + +#include +#include +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper +test1(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_difference(in, in, in, in, out); } + +output_iterator_wrapper +test2(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_difference(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..ae46d2201 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/2.cc @@ -0,0 +1,42 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_difference(iterator_type, iterator_type, + iterator_type, + iterator_type, iterator_type); + + template iterator_type set_difference(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..0aa9230a3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_difference(iterator_type, iterator_type, + iterator_type, + iterator_type, iterator_type); + + template iterator_type set_difference(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc new file mode 100644 index 000000000..09310ada1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc @@ -0,0 +1,131 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.3 [lib.set.intersection] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_intersection; + +typedef test_container Icontainer; +typedef test_container Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 2); + VERIFY(array3[0] == 1 && array3[1] == 2); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container SIcontainer; +typedef test_container SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -4}; + S array2[] = { 1, 1, 1, 1, 2, 3, 4, 4}; + S array3[5]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 8); + SOcontainer con3(array3, array3 + 5); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 5); + for(int i = 0; i < 5; ++i) + VERIFY(array3[i].j == 0); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/34730.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/34730.cc new file mode 100644 index 000000000..e9da465bc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/34730.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/34730 + +#include +#include +#include + +using namespace std; + +typedef pair intstring; + +struct intstrcmp +{ + bool + operator()(const string& x, const intstring& y) const + { return x < y.second; } + + bool + operator()(const intstring& x, const string& y) const + { return x.second < y; } +}; + +void test01() +{ + vector vec1; + vector vec2; + vector vec3; + set_intersection(vec2.begin(), vec2.end(), + vec1.begin(), vec1.end(), + back_inserter(vec3), intstrcmp()); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc new file mode 100644 index 000000000..62aff9a7d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.3 [lib.set.intersection] + +// { dg-do compile } + +#include +#include +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper +test1(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_intersection(in, in, in, in, out); } + +output_iterator_wrapper +test2(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_intersection(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..39f5a51fa --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/2.cc @@ -0,0 +1,42 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_intersection(iterator_type, iterator_type, + iterator_type, + iterator_type, iterator_type); + + template iterator_type set_intersection(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..025869afa --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_intersection(iterator_type, iterator_type, + iterator_type, + iterator_type, iterator_type); + + template iterator_type set_intersection(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc new file mode 100644 index 000000000..1eb1f1f48 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc @@ -0,0 +1,133 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.5 [lib.set.symmetric.difference] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_symmetric_difference; + +typedef test_container Icontainer; +typedef test_container Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2 + 1); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2 + 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,2,3}; + int array3[5]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 4); + Ocontainer con3(array3, array3 + 5); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array3 + 5); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 2 && + array3[3] == 3 && array3[4] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container SIcontainer; +typedef test_container SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -2, -2, -4, -5}; + S array2[] = { 1, 1, 1, 2, 3, 4}; + S array3[4]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 6); + SOcontainer con3(array3, array3 + 4); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array3 + 4); + VERIFY(array3[0].j == 1 && array3[1].j == 0 && array3[2].j == 1 && + array3[3].j == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc new file mode 100644 index 000000000..daafe6d86 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.5 [lib.set.symmetric.difference] + +// { dg-do compile } + +#include +#include +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper +test1(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_symmetric_difference(in, in, in, in, out); } + +output_iterator_wrapper +test2(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_symmetric_difference(in, in, in, in, out, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..a4199443f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/2.cc @@ -0,0 +1,42 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_symmetric_difference(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type); + + template iterator_type set_symmetric_difference(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..d5f198dba --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,41 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_symmetric_difference(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type); + + template iterator_type set_symmetric_difference(iterator_type, iterator_type, + iterator_type, iterator_type, + iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc new file mode 100644 index 000000000..f6445e9b9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc @@ -0,0 +1,136 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.2 [lib.set.union] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_union; + +typedef test_container Icontainer; +typedef test_container Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); + VERIFY(array2[0] == 1); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); + VERIFY(array2[0] == 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 6); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 6); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 1 && + array3[3] == 2 && array3[4] == 3 && array3[5] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container SIcontainer; +typedef test_container SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -4}; + S array2[] = { 1, 1, 1, 1, 2, 3, 4, 4}; + S array3[9]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 8); + SOcontainer con3(array3, array3 + 9); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 9); + VERIFY(array3[0].j == 0 && array3[1].j == 0 && array3[2].j == 0 && + array3[3].j == 1 && array3[4].j == 0 && array3[5].j == 0 && + array3[6].j == 1 && array3[7].j == 0 && array3[8].j == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc new file mode 100644 index 000000000..8ab069b7a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.5.2 [lib.set.union] + +// { dg-do compile } + +#include +#include +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper +test1(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_union(in, in, in, in, out); } + +output_iterator_wrapper +test2(input_iterator_wrapper& in, output_iterator_wrapper& out) +{ return std::set_union(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..3bdb35e85 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_union(iterator_type, iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type set_union(iterator_type, iterator_type, iterator_type, + iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..2488e343c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type set_union(iterator_type, iterator_type, iterator_type, + iterator_type, iterator_type); + + template iterator_type set_union(iterator_type, iterator_type, iterator_type, + iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/shuffle/1.cc b/libstdc++-v3/testsuite/25_algorithms/shuffle/1.cc new file mode 100644 index 000000000..b0e3574b4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/shuffle/1.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2010-03-19 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + for (unsigned size = 0; size < 50; ++size) + { + std::vector vref(size); + std::iota(vref.begin(), vref.end(), 0); + std::vector v1(vref), v2(vref); + + std::ranlux48_base g1(size), g2(size + 1); + std::shuffle(v1.begin(), v1.end(), g1); + std::shuffle(v2.begin(), v2.end(), g2); + + if (size >= 10) + { + VERIFY( !std::equal(v1.begin(), v1.end(), vref.begin()) ); + VERIFY( !std::equal(v2.begin(), v2.end(), vref.begin()) ); + VERIFY( !std::equal(v1.begin(), v1.end(), v2.begin()) ); + } + + for (unsigned ind = 0; ind < size; ++ind) + { + auto it1 = std::find(v1.begin(), v1.end(), vref[ind]); + auto it2 = std::find(v2.begin(), v2.end(), vref[ind]); + VERIFY( it1 != v1.end() ); + VERIFY( it2 != v2.end() ); + v1.erase(it1); + v2.erase(it2); + } + VERIFY( v1.empty() ); + VERIFY( v2.empty() ); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..840310248 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2010-03-19 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::mt19937_64 ugenerator_type; + + template void shuffle(iterator_type, iterator_type, ugenerator_type&&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..0f0a1e19e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/shuffle/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2010-03-19 Paolo Carlini + +// Copyright (C) 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::mt19937_64 ugenerator_type; + + template void shuffle(iterator_type, iterator_type, ugenerator_type&&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/sort/1.cc new file mode 100644 index 000000000..59f238675 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/1.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19}; +const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); +const int logN = 3; // ln(N) rounded up +const int P = 7; + +// comparison predicate for stable_sort: order by rightmost digit +struct CompLast +{ + bool + operator()(const int x, const int y) + { return x % 10 < y % 10; } +}; + +// This functor has the equivalent functionality of std::geater<>, +// but there is no dependency on and it also tracks the +// number of invocations since creation. +class Gt +{ +public: + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + + bool + operator()(const int& x, const int& y) + { + ++itsCount; + return x > y; + } + +private: + static int itsCount; +}; + +int Gt::itsCount = 0; + + +// 25.3.1.1 sort() +void +test01() +{ + int s1[N]; + std::copy(B, B + N, s1); + VERIFY(std::equal(s1, s1 + N, B)); + + std::sort(s1, s1 + N); + VERIFY(std::equal(s1, s1 + N, A)); + + Gt gt; + gt.reset(); + std::sort(s1, s1 + N, gt); + VERIFY(std::equal(s1, s1 + N, C)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/34095.cc b/libstdc++-v3/testsuite/25_algorithms/sort/34095.cc new file mode 100644 index 000000000..0d958e2d0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/34095.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/34095 +void test01() +{ + std::vector > v(20000); + std::sort(v.begin(), v.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/34636.cc b/libstdc++-v3/testsuite/25_algorithms/sort/34636.cc new file mode 100644 index 000000000..defd1f0db --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/34636.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +// libstdc++/34636 +void test01() +{ + std::vector > v(2); + std::sort(v.begin(), v.end()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/35588.cc b/libstdc++-v3/testsuite/25_algorithms/sort/35588.cc new file mode 100644 index 000000000..c16b96dfd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/35588.cc @@ -0,0 +1,31 @@ +// Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +// libstdc++/35588 +int main() +{ + using namespace std; + using namespace tr1; + using namespace std::tr1::placeholders; + + int t[10]; + sort(t, t+10, bind(less(), _1, _2)); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/check_compare_by_value.cc b/libstdc++-v3/testsuite/25_algorithms/sort/check_compare_by_value.cc new file mode 100644 index 000000000..ac3e2f7d4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/check_compare_by_value.cc @@ -0,0 +1,86 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; + +typedef __gnu_test::rvalstruct_compare_by_value V; +typedef test_container Container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::sort(con.begin(), con.end()); + VERIFY( s1[0].ok ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::sort(con.begin(), con.end(), __gnu_test::order); + VERIFY( s1[0].ok ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + + V vvs[] = { 2, 0 }; + std::sort(vvs, vvs + 2); + VERIFY( vvs[0].ok && vvs[0].val == 0 ); + VERIFY( vvs[1].ok && vvs[1].val == 2 ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/sort/moveable.cc new file mode 100644 index 000000000..a46411d5a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/moveable.cc @@ -0,0 +1,84 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; +using std::partial_sort; + +typedef test_container Container; + +const int A[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19}; +const int N = sizeof(A) / sizeof(int); + +// 25.3.1.1 sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::sort(con.begin(), con.end()); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +bool order(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +// 25.3.1.1 sort() +void +test02() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::sort(con.begin(), con.end(), order); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..47231bcf9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void sort(iterator_type, iterator_type); + template void sort(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..14e21f4e6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void sort(iterator_type, iterator_type); + template void sort(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort/vectorbool.cc b/libstdc++-v3/testsuite/25_algorithms/sort/vectorbool.cc new file mode 100644 index 000000000..bb38ad10f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort/vectorbool.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#include +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + std::vector b; + b.push_back(false); + b.push_back(true); + b.push_back(false); + b.push_back(true); + std::sort(b.begin(), b.end()); + VERIFY( b[0] == false && b[1] == false && b[2] == true && b[3] == true ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort_heap/check_compare_by_value.cc b/libstdc++-v3/testsuite/25_algorithms/sort_heap/check_compare_by_value.cc new file mode 100644 index 000000000..32cff8fd8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort_heap/check_compare_by_value.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; + +typedef __gnu_test::rvalstruct_compare_by_value V; +typedef test_container Container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::make_heap(con.begin(), con.end()); + std::sort_heap(con.begin(), con.end()); + VERIFY( s1[0].ok ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::make_heap(con.begin(), con.end(), __gnu_test::order); + std::sort_heap(con.begin(), con.end(), __gnu_test::order); + VERIFY( s1[0].ok ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + V vvs[] = { 2, 0 }; + std::make_heap(vvs, vvs + 2); + std::sort_heap(vvs, vvs + 2); + VERIFY( vvs[0].ok && vvs[0].val == 0 ); + VERIFY( vvs[1].ok && vvs[1].val == 2 ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..3e06f00ac --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void sort_heap(iterator_type, iterator_type); + template void sort_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..0479f1de6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/sort_heap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void sort_heap(iterator_type, iterator_type); + template void sort_heap(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/1.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/1.cc new file mode 100644 index 000000000..a77e88938 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/1.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N = sizeof(A) / sizeof(int); + +struct Pred +{ + bool + operator()(const int& x) const + { return (x % 2) == 0; } +}; + +// 25.2.12 stable_partition() +void +test02() +{ + using std::stable_partition; + + int s1[N]; + std::copy(A, A + N, s1); + + stable_partition(s1, s1 + N, Pred()); + VERIFY(std::equal(s1, s1 + N, B)); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/mem_check.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/mem_check.cc new file mode 100644 index 000000000..81d816d36 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/mem_check.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::copy_tracker; +using __gnu_test::copy_constructor; +using __gnu_test::assignment_operator; +using __gnu_test::destructor; + +typedef test_container Container; + +const int A[] = {10, 20, 1, 11, 2, 21, 28, 29, 12, 35, 15, 27, 6, 16, 7, + 25, 17, 8, 23, 18, 9, 19, 24, 30, 13, 4, 14, 22, 26}; + +bool even(const copy_tracker& ct) +{ return ct.id() < 19; } + +void +test1(int throw_count) +{ + bool test __attribute__((unused)) = true; + + copy_tracker vals[30]; + for(int i = 0; i < 30; ++i) + vals[i] = A[i]; + + Container con(vals, vals + 30); + copy_tracker::reset(); + copy_constructor::throw_on(throw_count); + int throw_occurred = 0; + try + { + std::stable_partition(con.begin(), con.end(), even); + } + catch(...) + { + throw_occurred = 1; + } + + // If a throw occurred in copy_constructor, we will end up with one more + // copy_construct than destructor. + VERIFY( destructor::count() == copy_constructor::count() - throw_occurred ); +} + +int main() +{ + for(int i = 0; i < 32; ++i) + test1(i); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc new file mode 100644 index 000000000..214c21d60 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc @@ -0,0 +1,88 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010, 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [lib.alg.partitions] Partitions. + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N = sizeof(A) / sizeof(int); + +// Check that starting with a true predicate works too. (PR52822) +const int A2[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B2[] = {2, 4, 6, 8, 10, 12, 14, 16, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N2 = sizeof(A2) / sizeof(int); + +struct Pred +{ + bool + operator()(const rvalstruct& x) const + { return (x.val % 2) == 0; } +}; + +// 25.2.12 stable_partition(), starting with a false predicate. +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + + std::stable_partition(con.begin(), con.end(), Pred()); + VERIFY( std::equal(s1, s1 + N, B) ); +} + +// 25.2.12 stable_partition(), starting with a true predicate. +void +test02() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N2]; + std::copy(A2, A2 + N2, s1); + Container con(s1, s1 + N2); + + std::stable_partition(con.begin(), con.end(), Pred()); + VERIFY( std::equal(s1, s1 + N2, B2) ); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc new file mode 100644 index 000000000..7a3d214e3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include +#include +#include + +bool true_vector_pred(const std::vector&) { return true; } + +void +test01() +{ + std::vector > v(1); + v[0].push_back(7); + VERIFY( v[0].size() == 1 ); + std::stable_partition(v.begin(), v.end(), &true_vector_pred); + VERIFY( v[0].size() == 1 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..3e38cb284 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type stable_partition(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..42091e800 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_partition/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function predicate_type; + + template iterator_type stable_partition(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc new file mode 100644 index 000000000..b8a057178 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.2 [lib.stable.sort] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::stable_sort; + +typedef test_container Container; + +void +test1() +{ + int array[]={0}; + Container con(array, array); + stable_sort(con.begin(), con.end()); +} + +void +test2() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + stable_sort(con.begin(), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4 && array[5] == 5 && + array[6] == 6); +} +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +void +test3() +{ + + S array[] = {-1, -2, 1, 2, -3 ,-5 ,3 , -4, 5, 4}; + test_container con(array,array + 10); + stable_sort(con.begin(), con.end()); + for(int i = 0; i < 10; ++i) + VERIFY(array[i].j == i % 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/2.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/2.cc new file mode 100644 index 000000000..898daaf5c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/2.cc @@ -0,0 +1,88 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1 algorithms, sort() + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; +const int B[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19}; +const int C[] = {20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); +const int logN = 3; // ln(N) rounded up +const int P = 7; + +// comparison predicate for stable_sort: order by rightmost digit +struct CompLast +{ + bool + operator()(const int x, const int y) + { return x % 10 < y % 10; } +}; + +// This functor has the equivalent functionality of std::geater<>, +// but there is no dependency on and it also tracks the +// number of invocations since creation. +class Gt +{ +public: + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + + bool + operator()(const int& x, const int& y) + { + ++itsCount; + return x > y; + } + +private: + static int itsCount; +}; + +int Gt::itsCount = 0; + +// 25.3.1.2 stable_sort() +void +test02() +{ + int s1[N]; + std::copy(A, A + N, s1); + VERIFY(std::equal(s1, s1 + N, A)); + + std::stable_sort(s1, s1 + N, CompLast()); + VERIFY(std::equal(s1, s1 + N, B)); + + std::stable_sort(s1, s1 + N); + VERIFY(std::equal(s1, s1 + N, A)); + + Gt gt; + gt.reset(); + std::stable_sort(s1, s1 + N, gt); + VERIFY(std::equal(s1, s1 + N, C)); + VERIFY(gt.count() <= N * logN * logN); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/49559.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/49559.cc new file mode 100644 index 000000000..544511793 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/49559.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +const int A[] = { 10 }; +const int N = 1; + +bool order(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +// libstdc++/49559 +void test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[1]; + std::copy(A, A + 1, s1); + Container con1(s1, s1 + 1); + std::stable_sort(con1.begin(), con1.end()); + VERIFY( s1[0] == 10 ); + VERIFY( s1[0].valid ); + + rvalstruct s2[1]; + std::copy(A, A + 1, s2); + Container con2(s2, s2 + 1); + std::stable_sort(con2.begin(), con2.end(), order); + VERIFY( s2[0] == 10 ); + VERIFY( s2[0].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_compare_by_value.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_compare_by_value.cc new file mode 100644 index 000000000..817468c16 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_compare_by_value.cc @@ -0,0 +1,90 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; + +typedef __gnu_test::rvalstruct_compare_by_value V; +typedef test_container Container; + +void +test01() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end()); + VERIFY( s1[0].ok ); + for(int i = 1; i < N; ++i) + { + VERIFY( s1[i].val > s1[i - 1].val); + VERIFY( s1[i].ok ); + } +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + + V s1[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; + const int N = sizeof(s1) / sizeof(V); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end(), __gnu_test::order); + VERIFY( s1[0].ok ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val > s1[i - 1].val && s1[i].ok ); +} + +void +test03() +{ + bool test __attribute__((unused)) = true; + + V vvs[] = { 2, 0 }; + std::stable_sort(vvs, vvs + 2); + VERIFY( vvs[0].ok && vvs[0].val == 0 ); + VERIFY( vvs[1].ok && vvs[1].val == 2 ); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc new file mode 100644 index 000000000..962807bd4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.1 [lib.stable.sort] + +// { dg-do compile } + +#include +#include + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper& s) +{ + std::stable_sort(s, s); +} + +void +test2(random_access_iterator_wrapper& x) +{ + std::stable_sort(x, x, predicate); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/mem_check.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/mem_check.cc new file mode 100644 index 000000000..78c14b43e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/mem_check.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.2 [lib.stable.sort] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::copy_tracker; +using __gnu_test::copy_constructor; +using __gnu_test::assignment_operator; +using __gnu_test::destructor; + +typedef test_container Container; + +const int A[] = {10, 20, 1, 11, 2, 21, 28, 29, 12, 35, 15, 27, 6, 16, 7, + 25, 17, 8, 23, 18, 9, 19, 24, 30, 13, 4, 14, 22, 26}; + +void +test_mem1(int throw_count) +{ + bool test __attribute__((unused)) = true; + + copy_tracker vals[30]; + for(int i = 0; i < 30; ++i) + vals[i] = A[i]; + + Container con(vals, vals + 30); + copy_tracker::reset(); + copy_constructor::throw_on(throw_count); + int throw_occurred = 0; + try + { + std::stable_sort(con.begin(), con.end()); + } + catch(...) + { + throw_occurred = 1; + } + + // If a throw occurred in copy_constructor, we will end up with one more + // copy_construct than destructor. + VERIFY( destructor::count() == copy_constructor::count() - throw_occurred ); +} + +bool +is_ordered(const copy_tracker& lhs, const copy_tracker& rhs) +{ return lhs < rhs; } + +void +test_mem2(int throw_count) +{ + bool test __attribute__((unused)) = true; + + copy_tracker vals[30]; + for(int i = 0; i < 30; ++i) + vals[i] = A[i]; + + Container con(vals, vals + 30); + copy_tracker::reset(); + copy_constructor::throw_on(throw_count); + int throw_occurred = 0; + try + { + std::stable_sort(con.begin(), con.end(), is_ordered); + } + catch(...) + { + throw_occurred = 1; + } + + // If a throw occurred in copy_constructor, we will end up with one more + // copy_construct than destructor. + VERIFY( destructor::count() == copy_constructor::count() - throw_occurred ); +} + +int main() +{ + for(int i = 0; i < 60; ++i) + { + test_mem1(i); + test_mem2(i); + } + + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc new file mode 100644 index 000000000..4e4a6605f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable.cc @@ -0,0 +1,63 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; +const int N = sizeof(A) / sizeof(int); + +// 25.3.1.2 stable_sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end()); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc new file mode 100644 index 000000000..5ac80078b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/moveable2.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.1.2 [lib.stable.sort] + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, + 17, 8, 18, 9, 19 }; +const int N = sizeof(A) / sizeof(int); + +bool order(const rvalstruct& lhs, const rvalstruct& rhs) +{ return lhs < rhs; } + +// 25.3.1.2 stable_sort() +void +test01() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N]; + std::copy(A, A + N, s1); + Container con(s1, s1 + N); + std::stable_sort(con.begin(), con.end(), order); + VERIFY( s1[0].valid ); + for(int i = 1; i < N; ++i) + VERIFY( s1[i].val>s1[i-1].val && s1[i].valid ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..cca14d8d9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void stable_sort(iterator_type, iterator_type); + template void stable_sort(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..f4df71bed --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template void stable_sort(iterator_type, iterator_type); + template void stable_sort(iterator_type, iterator_type, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc b/libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc new file mode 100644 index 000000000..e8c404e5f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap/dr809.cc @@ -0,0 +1,46 @@ +// { dg-do compile } + +// Copyright (C) 2008, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +template + class W + { + public: + T data; + }; + +template + void + swap(W& x, W& y) + { + using std::swap; + swap(x.data, y.data); + } + +// DR 809. std::swap should be overloaded for array types. +void test01() +{ + W w1, w2; // Two objects of a Swappable type. + + using std::swap; + swap(w1, w2); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..0c8a54838 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/2.cc @@ -0,0 +1,33 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + + template void swap(value_type&, value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..671b6fdf5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,34 @@ + +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + + template void swap(value_type&, value_type&); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc new file mode 100644 index 000000000..a79bb5401 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc @@ -0,0 +1,59 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.2 swap_ranges + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container Container; + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array1[]={1, 2}; + int array2[]={3, 4}; + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY(std::swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == + array2 + 2); + VERIFY(array1[0] == 3 && array1[1] == 4 && array2[0] == 1 && array2[1] == 2); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1}; + int array2[] = {1}; + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY(swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc new file mode 100644 index 000000000..a79a3d4e1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 Swap Ranges + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct X { +}; + +void +test1(forward_iterator_wrapper& begin, + forward_iterator_wrapper& end, + forward_iterator_wrapper& begin2) +{ std::swap_ranges(begin, end, begin2); } diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/moveable.cc new file mode 100644 index 000000000..5377ea838 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/moveable.cc @@ -0,0 +1,43 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.4 Swap Ranges + +#undef _GLIBCXX_CONCEPT_CHECKS + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +class X +{ + X(); + X(const X&); + void operator=(const X&); +}; + +void +swap(X&, X&) { } + +void +test1(forward_iterator_wrapper& begin, forward_iterator_wrapper& end, + forward_iterator_wrapper& begin2) +{ std::swap_ranges(begin, end, begin2); } diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..2f5991880 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + + template iterator_type swap_ranges(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..6e53a6773 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,35 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + + template iterator_type swap_ranges(iterator_type, iterator_type, + iterator_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..803692c02 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/2.cc @@ -0,0 +1,40 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function operator1_type; + typedef std::pointer_to_binary_function operator2_type; + + template iterator_type transform(iterator_type, iterator_type, iterator_type, + operator1_type); + template iterator_type transform(iterator_type, iterator_type, iterator_type, + iterator_type, operator2_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..7e17f1e7a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/transform/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::pointer_to_unary_function operator1_type; + typedef std::pointer_to_binary_function operator2_type; + + template iterator_type transform(iterator_type, iterator_type, iterator_type, + operator1_type); + template iterator_type transform(iterator_type, iterator_type, iterator_type, + iterator_type, operator2_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/1.cc b/libstdc++-v3/testsuite/25_algorithms/unique/1.cc new file mode 100644 index 000000000..f7e3b5e7d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/1.cc @@ -0,0 +1,32 @@ +// 2001-07-19 Peter Schmid + +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.8 [lib.alg.unique] Unique + +#include +#include + +int main() +{ + using namespace std; + list menge; + unique (menge.begin(), menge.end()); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/11480.cc b/libstdc++-v3/testsuite/25_algorithms/unique/11480.cc new file mode 100644 index 000000000..f165dac54 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/11480.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2003, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +int a[10] = { 1, 2, 3, 3, 4, 5, 5, 6, 7, 9 }; + +static int compare_count = 0; + +bool compare(int a, int b) +{ + compare_count++; + return a == b; +} + +// libstdc++/11480 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::unique(a, a+10, compare); + VERIFY( compare_count == 9 ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/2.cc b/libstdc++-v3/testsuite/25_algorithms/unique/2.cc new file mode 100644 index 000000000..cae1b1672 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/2.cc @@ -0,0 +1,94 @@ +// 2003-10-14 Paolo Carlini + +// Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.8 [lib.alg.unique] Unique + +#include +#include +#include +#include + +const int T1[] = {1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4}; +const int T2[] = {1, 1, 1, 2, 2, 1, 1, 7, 6, 6, 7, 8, 8, 8, 8, 9, 9}; +const int N = sizeof(T1) / sizeof(int); + +const int A1[] = {1, 4, 6, 1, 2, 3, 1, 6, 5, 7, 5, 4}; +const int A2[] = {1, 4, 4, 6, 6, 6, 6, 7}; +const int A3[] = {1, 1, 1}; + +const int B1[] = {1, 2, 1, 7, 6, 7, 8, 9}; +const int B2[] = {1, 1, 1, 2, 2, 7, 7, 8, 8, 8, 8, 9, 9}; +const int B3[] = {9, 9, 8, 8, 8, 8, 7, 6, 6, 1, 1, 1, 1, 1}; + +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + list::iterator pos; + + list coll(T1, T1 + N); + pos = unique(coll.begin(), coll.end()); + VERIFY( equal(coll.begin(), pos, A1) ); + + list coll2(T2, T2 + N); + pos = unique(coll2.begin(), coll2.end()); + VERIFY( equal(coll2.begin(), pos, B1) ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + list::iterator pos; + + list coll(T1, T1 + N); + pos = unique(coll.begin(), coll.end(), greater()); + VERIFY( equal(coll.begin(), pos, A2) ); + + list coll2(T2, T2 + N); + pos = unique(coll2.begin(), coll2.end(), greater()); + VERIFY( equal(coll2.begin(), pos, B2) ); +} + +void test03() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + list::iterator pos; + + list coll(T1, T1 + N); + pos = unique(coll.begin(), coll.end(), less()); + VERIFY( equal(coll.begin(), pos, A3) ); + + list coll2(T2, T2 + N); + reverse(coll2.begin(), coll2.end()); + pos = unique(coll2.begin(), coll2.end(), less()); + VERIFY( equal(coll2.begin(), pos, B3) ); +} + +int main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/moveable.cc b/libstdc++-v3/testsuite/25_algorithms/unique/moveable.cc new file mode 100644 index 000000000..fd6da1168 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/moveable.cc @@ -0,0 +1,110 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.8 [lib.alg.unique] Unique + +#undef _GLIBCXX_CONCEPT_CHECKS + +// XXX FIXME: parallel-mode should deal correctly with moveable-only types +// per C++0x, at minimum smoothly fall back to serial. +#undef _GLIBCXX_PARALLEL + +#include +#include +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::rvalstruct; + +typedef test_container Container; + +void test01() +{ + bool test __attribute__((unused)) = true; + + int intarray1[] = {1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4}; + int intarray2[] = {1, 1, 1, 2, 2, 1, 1, 7, 6, 6, 7, 8, 8, 8, 8, 9, 9}; + + const int N = sizeof(intarray1) / sizeof(int); + + rvalstruct T1[N]; + rvalstruct T2[N]; + + std::copy(intarray1,intarray1 + N, T1); + std::copy(intarray2,intarray2 + N, T2); + + const int A1[] = {1, 4, 6, 1, 2, 3, 1, 6, 5, 7, 5, 4}; + const int B1[] = {1, 2, 1, 7, 6, 7, 8, 9}; + + Container con(T1, T1 + N); + + VERIFY( std::unique(con.begin(), con.end()).ptr - T1 == 12 ); + for(int i = 0; i < 12; ++i) + VERIFY( T1[i].val == A1[i] ); + + Container con2(T2, T2 + N); + VERIFY( std::unique(con2.begin(), con2.end()).ptr - T2 == 8 ); + for(int i = 0; i < 8; ++i) + VERIFY( T2[i].val == B1[i] ); +} + +bool are_equal(const rvalstruct& rhs, const rvalstruct& lhs) +{ return rhs == lhs; } + +void test02() +{ + bool test __attribute__((unused)) = true; + + int intarray1[] = {1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4}; + int intarray2[] = {1, 1, 1, 2, 2, 1, 1, 7, 6, 6, 7, 8, 8, 8, 8, 9, 9}; + + const int N = sizeof(intarray1) / sizeof(int); + + rvalstruct T1[N]; + rvalstruct T2[N]; + + std::copy(intarray1,intarray1 + N, T1); + std::copy(intarray2,intarray2 + N, T2); + + const int A1[] = {1, 4, 6, 1, 2, 3, 1, 6, 5, 7, 5, 4}; + const int B1[] = {1, 2, 1, 7, 6, 7, 8, 9}; + + Container con(T1, T1 + N); + + VERIFY( std::unique(con.begin(), con.end(), are_equal).ptr - T1 == 12 ); + for(int i = 0; i < 12; ++i) + VERIFY( T1[i].val == A1[i] ); + + Container con2(T2, T2 + N); + VERIFY( std::unique(con2.begin(), con2.end(), are_equal).ptr - T2 == 8 ); + for(int i = 0; i < 8; ++i) + VERIFY( T2[i].val == B1[i] ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..3a004b136 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less predicate_type; + + template iterator_type unique(iterator_type, iterator_type); + template iterator_type unique(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..45dea5bf8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,36 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less predicate_type; + + template iterator_type unique(iterator_type, iterator_type); + template iterator_type unique(iterator_type, iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc new file mode 100644 index 000000000..ca79b354c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.8 [lib.alg.unique] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::unique_copy; + +typedef test_container Icontainer; +typedef test_container Fcontainer; +typedef test_container Ocontainer; + +int array1[] = {0, 0, 0, 1, 1, 1}; +int array2[2]; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1); + Ocontainer con2(array2, array2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2 ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1 + 6); + Ocontainer con2(array2, array2 + 2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2 ); + VERIFY( array2[0] == 0 && array2[1] == 1 ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1); + Fcontainer con2(array2, array2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2 ); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1 + 6); + Fcontainer con2(array2, array2 + 2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2 ); + VERIFY( array2[0] == 0 && array2[1] == 1 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc new file mode 100644 index 000000000..f0879a4d1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/2.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.2.8 [lib.alg.unique] + +#include +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::unique_copy; +using std::equal_to; + +typedef test_container Fcontainer; +typedef test_container Ocontainer; + +int array1[] = {0, 0, 0, 1, 1, 1}; +int array2[2]; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Fcontainer con1(array1, array1); + Ocontainer con2(array2, array2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2 ); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Fcontainer con1(array1, array1 + 6); + Ocontainer con2(array2, array2 + 2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2 ); + VERIFY( array2[0] == 0 && array2[1] == 1 ); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Fcontainer con1(array1, array1); + Ocontainer con2(array2, array2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin(), + equal_to()).ptr == array2 ); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Fcontainer con1(array1, array1 + 6); + Ocontainer con2(array2, array2 + 2); + VERIFY( unique_copy(con1.begin(), con1.end(), con2.begin(), + equal_to()).ptr == array2 + 2 ); + VERIFY( array2[0] == 0 && array2[1] == 1 ); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/26133.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/26133.cc new file mode 100644 index 000000000..009c1a3a9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/26133.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2006, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include +#include + +struct no_assign +{ + int const x; + no_assign() : x(23) { } + operator int() const { return x; } +}; + +// libstdc++/26133 +void test01() +{ + bool test __attribute__((unused)) = true; + std::ostringstream oss1, oss2; + + no_assign in[4]; + + std::unique_copy(in, in + 4, std::ostream_iterator(oss1, "\n")); + VERIFY( oss1.str() == "23\n" ); + + std::unique_copy(in, in + 4, std::ostream_iterator(oss2, "\n"), + std::equal_to()); + VERIFY( oss2.str() == "23\n" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc new file mode 100644 index 000000000..9b5342074 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.5.8 [lib.alg.unique_copy] + +// { dg-do compile } + +#include +#include + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S1 { }; + +struct S2 +{ + S2(const S1&) {} +}; + +bool +operator==(const S1&, const S1&) {return true;} + +struct X1 { }; + +struct X2 +{ + X2(const X1&) {} +}; + +bool +predicate(const X1&, const X1&) {return true;} + +output_iterator_wrapper +test1(input_iterator_wrapper& s1, output_iterator_wrapper& s2) +{ return std::unique_copy(s1, s1, s2); } + +output_iterator_wrapper +test2(input_iterator_wrapper& x1, output_iterator_wrapper& x2) +{ return std::unique_copy(x1, x1, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..1b2283ada --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/2.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* in_iterator_type; + typedef value_type* out_iterator_type; + typedef std::less predicate_type; + + template out_iterator_type unique_copy(in_iterator_type, in_iterator_type, out_iterator_type); + template out_iterator_type unique_copy(in_iterator_type, in_iterator_type, out_iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..15508973a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,37 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* in_iterator_type; + typedef value_type* out_iterator_type; + typedef std::less predicate_type; + + template out_iterator_type unique_copy(in_iterator_type, in_iterator_type, out_iterator_type); + template out_iterator_type unique_copy(in_iterator_type, in_iterator_type, out_iterator_type, predicate_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc new file mode 100644 index 000000000..7b46e0143 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.2 [lib.upper.bound] + +#include +#include +#include + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::upper_bound; + +typedef test_container Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1}; + +void +test1() +{ + for(int i = 0; i < 5; ++i) + for(int j = 4; j < 7; ++j) + { + Container con(array + i, array + j); + VERIFY(upper_bound(con.begin(), con.end(), 0).ptr == array + 4); + } +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/2.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/2.cc new file mode 100644 index 000000000..cbf287076 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/2.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2001, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3 [lib.alg.binary.search] Binary search algorithms. + +#include +#include + +bool test __attribute__((unused)) = true; + +const int A[] = {1, 2, 3, 3, 3, 5, 8}; +const int C[] = {8, 5, 3, 3, 3, 2, 1}; +const int N = sizeof(A) / sizeof(int); + +// A comparison, equalivalent to std::greater without the +// dependency on . +struct gt +{ + bool + operator()(const int& x, const int& y) const + { return x > y; } +}; + +// Each test performs general-case, bookend, not-found condition, +// and predicate functional checks. + +// 25.3.3.2 upper_bound, with and without comparison predicate +void +test02() +{ + using std::upper_bound; + + const int first = A[0]; + const int last = A[N - 1]; + + const int* p = upper_bound(A, A + N, 3); + VERIFY(p == A + 5); + + const int* q = upper_bound(A, A + N, first); + VERIFY(q == A + 1); + + const int* r = upper_bound(A, A + N, last); + VERIFY(r == A + N); + + const int* s = upper_bound(A, A + N, 4); + VERIFY(s == A + 5); + + const int* t = upper_bound(C, C + N, 3, gt()); + VERIFY(t == C + 5); + + const int* u = upper_bound(C, C + N, first, gt()); + VERIFY(u == C + N); + + const int* v = upper_bound(C, C + N, last, gt()); + VERIFY(v == C + 1); + + const int* w = upper_bound(C, C + N, 4, gt()); + VERIFY(w == C + 2); +} + +int +main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/33613.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/33613.cc new file mode 100644 index 000000000..3a106938c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/33613.cc @@ -0,0 +1,36 @@ +// 2007-10-02 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/33613 + +#include + +struct A { }; +struct B { }; + +bool ba(B, A); + +void test01(A* a, B b) +{ + std::upper_bound(a, a, b, ba); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc new file mode 100644 index 000000000..244c42992 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// 25.3.3.2 [lib.upper.bound] + +// { dg-do compile } + +#include +#include + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper +test1(forward_iterator_wrapper& s) +{ return std::upper_bound(s, s, *s); } + +forward_iterator_wrapper +test2(forward_iterator_wrapper& x) +{ return std::upper_bound(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..5efb4cfb6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/2.cc @@ -0,0 +1,39 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include +#include + +namespace std +{ + using __gnu_test::NonDefaultConstructible; + + typedef NonDefaultConstructible value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type upper_bound(iterator_type, iterator_type, + const value_type&); + template iterator_type upper_bound(iterator_type, iterator_type, + const value_type&, compare_type); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/pod.cc new file mode 100644 index 000000000..5fbd2c38e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/requirements/explicit_instantiation/pod.cc @@ -0,0 +1,38 @@ +// { dg-do compile } + +// 2007-09-20 Benjamin Kosnik + +// Copyright (C) 2007, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + + +#include +#include + +namespace std +{ + using __gnu_test::pod_int; + + typedef pod_int value_type; + typedef value_type* iterator_type; + typedef std::less compare_type; + + template iterator_type upper_bound(iterator_type, iterator_type, + const value_type&); + template iterator_type upper_bound(iterator_type, iterator_type, + const value_type&, compare_type); +} -- cgit v1.2.3