aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2009-07-02 17:23:17 +0000
committerJan Hubicka <jh@suse.cz>2009-07-02 17:23:17 +0000
commitf51339722dfe03c2c940f1f6a5d1da3ba7fdd494 (patch)
tree6c3047e929fbfd34e59f2edadc84f34640bb8080 /libstdc++-v3
parent4b46e9306fb479712b8866c61bec0aae3cd26e0c (diff)
Merge from mainline.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/pretty-ipa@149187 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog388
-rw-r--r--libstdc++-v3/config/abi/pre/gnu.ver3
-rw-r--r--libstdc++-v3/config/locale/gnu/c_locale.cc4
-rw-r--r--libstdc++-v3/configure.host4
-rw-r--r--libstdc++-v3/doc/doxygen/user.cfg.in5
-rw-r--r--libstdc++-v3/include/Makefile.am1
-rw-r--r--libstdc++-v3/include/Makefile.in1
-rw-r--r--libstdc++-v3/include/bits/atomic_0.h36
-rw-r--r--libstdc++-v3/include/bits/atomic_2.h32
-rw-r--r--libstdc++-v3/include/bits/basic_string.h29
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc23
-rw-r--r--libstdc++-v3/include/bits/move.h14
-rw-r--r--libstdc++-v3/include/bits/random.h510
-rw-r--r--libstdc++-v3/include/bits/random.tcc418
-rw-r--r--libstdc++-v3/include/bits/shared_ptr.h22
-rw-r--r--libstdc++-v3/include/debug/macros.h2
-rw-r--r--libstdc++-v3/include/std/future925
-rw-r--r--libstdc++-v3/include/std/ratio2
-rw-r--r--libstdc++-v3/include/std/thread4
-rw-r--r--libstdc++-v3/libsupc++/exception_ptr.h12
-rw-r--r--libstdc++-v3/python/Makefile.am23
-rw-r--r--libstdc++-v3/python/Makefile.in18
-rw-r--r--libstdc++-v3/python/hook.in41
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py24
-rw-r--r--libstdc++-v3/src/Makefile.am6
-rw-r--r--libstdc++-v3/src/Makefile.in17
-rw-r--r--libstdc++-v3/src/future.cc73
-rw-r--r--libstdc++-v3/testsuite/18_support/exception_ptr/move.cc45
-rw-r--r--libstdc++-v3/testsuite/20_util/owner_less/cmp.cc28
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc20
-rw-r--r--libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/swap.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc4
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/capacity/1.cc45
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/capacity/1.h61
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc64
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h79
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/1.cc49
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/1.h63
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/2.cc61
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/2.h77
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/3.cc32
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/3.h48
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/4.cc45
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/4.h61
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/5.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/5.h51
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/6.cc48
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/6.h64
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/7.cc49
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/7.h65
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/8.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/8.h51
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/9.cc43
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/9.h59
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc63
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h78
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/init-list.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/init-list.h65
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/invalidation/1.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/invalidation/2.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/invalidation/3.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/invalidation/4.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc97
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/1.h113
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc70
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/2.h86
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc102
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/3.h118
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc78
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h90
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc41
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h58
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc109
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h127
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc138
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h156
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/moveable.cc25
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/moveable.h41
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/1.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/1.h68
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/2.cc38
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/2.h54
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/3.cc52
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/3.h68
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/4.cc75
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/4.h92
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/5.cc116
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/operations/5.h134
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/minmax/2.cc20
-rw-r--r--libstdc++-v3/testsuite/25_algorithms/minmax/3.cc4
-rw-r--r--libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc5
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc2
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc4
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc4
-rw-r--r--libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc26
-rw-r--r--libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc49
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc53
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc64
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc36
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc49
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc49
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc47
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc55
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc57
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc49
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc56
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc60
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc48
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc51
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc65
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc53
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc49
-rw-r--r--libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/cons/1.cc46
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc36
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/cons/move.cc55
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc56
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc52
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc57
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc49
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc95
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc105
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc88
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc87
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/members/swap.cc46
-rw-r--r--libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc38
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc42
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/cons/default_neg.cc45
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc41
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc78
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc127
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/has_exception.cc70
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/has_value.cc70
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/is_ready.cc51
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc56
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc56
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc64
-rw-r--r--libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc38
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc37
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/cons/default_neg.cc45
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/cons/move.cc41
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/get.cc70
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/get2.cc97
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/has_exception.cc64
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/has_value.cc65
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/is_ready.cc48
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/wait.cc54
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/wait_for.cc53
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/members/wait_until.cc58
-rw-r--r--libstdc++-v3/testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc34
-rw-r--r--libstdc++-v3/testsuite/performance/30_threads/future/polling.cc55
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_common_types.h14
158 files changed, 7571 insertions, 2232 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9d3bf47053e..963bc23f399 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,391 @@
+2009-06-30 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/40600
+ * testsuite/25_algorithms/minmax/2.cc: Fix consistently with
+ std::minmax return type.
+ * testsuite/25_algorithms/minmax/3.cc: Likewise.
+
+2009-06-30 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/40511
+ * config/locale/gnu/c_locale.cc: Don't use LC_CTYPE_MASK together
+ with glibc2.2.x.
+
+2009-06-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/random.tcc
+ (linear_congruential_engine<>::seed(seed_seq&)): Use uint_least32_t
+ as array type.
+
+2009-06-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/random.h (__mod(_Tp)): Use defaults.
+ (struct _Mod): Adjust template parameters.
+ (linear_congruential_engine<>::operator()()): Adjust.
+ (typedef _UInt32Type): Remove.
+ (mersenne_twister_engine<>::initialization_multiplier): Fix type.
+ * include/bits/random.tcc (struct _Mod): Adjust template parameters.
+ (linear_congruential_engine<>::seed(result_type)): Adjust __mod
+ calls.
+ (mersenne_twister_engine<>::seed(result_type)): Likewise.
+ (mersenne_twister_engine<>::seed(seed_seq&)): Likewise.
+ (subtract_with_carry_engine<>::seed(result_type)): Likewise.
+ (subtract_with_carry_engine<>::seed(seed_seq&)): Likewise.
+ (seed_seq::seed_seq(std::initializer_list<>)): Likewise.
+ (seed_seq::seed_seq(_InputIterator, _InputIterator)): Likewise.
+ (seed_seq::generate(_RandomAccessIterator, _RandomAccessIterator)):
+ Likewise.
+
+ * include/bits/random.tcc
+ (mersenne_twister_engine<>::seed(result_type)): Fix i usage in the
+ formula (i mod n).
+ (mersenne_twister_engine<>::seed(seed_seq&)): Use uint_least32_t
+ as array type.
+ (subtract_with_carry_engine<>::seed(seed_seq&)): Likewise; fix array
+ size.
+ (subtract_with_carry_engine<>::seed(result_type)): Fix; also use
+ uint_least32_t.
+
+2009-06-24 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/std/future (shared_future): Adjust doxygen comment.
+
+2009-06-24 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ PR libstdc++/40297
+ * include/bits/atomic_0.h: Reverse debug assertions.
+ * include/bits/atomic_2.h: Likewise.
+
+2009-06-23 DJ Delorie <dj@redhat.com>
+
+ Add MeP port.
+ * configure.host: Add mep support.
+
+2009-06-23 Benjamin Kosnik <bkoz@redhat.com>
+
+ * doc/doxygen/user.cfg.in (PREDEFINED): Add _GLIBCXX_ATOMIC_BUILTINS_*.
+ (INPUT): Add future.
+ * include/std/future: Adjust markup.
+ * testsuite/30_threads/shared_future/cons/assign_neg.cc: Adjust
+ line numbers.
+ * testsuite/30_threads/unique_future/cons/assign_neg.cc: Same.
+ * testsuite/30_threads/unique_future/cons/copy_neg.cc: Same.
+ * testsuite/30_threads/promise/cons/assign_neg.cc: Same.
+ * testsuite/30_threads/promise/cons/copy_neg.cc: Same.
+
+2009-06-23 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/bits/shared_ptr.h: Do not swap rvalues.
+ * testsuite/20_util/owner_less/cmp.cc: Add missing test variables.
+ * testsuite/20_util/shared_ptr/comparison/cmp.cc: Likewise.
+ * testsuite/20_util/shared_ptr/comparison/less.cc: Likewise.
+ * testsuite/20_util/weak_ptr/observers/owner_before.cc: Likewise.
+ * testsuite/20_util/tuple/swap.cc: Likewise.
+
+2009-06-23 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/debug/macros.h: Replace @tbd with valid doxygen tag @todo.
+ * include/std/ratio: Typo in comment.
+
+2009-06-23 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/40518
+ * include/bits/basic_string.h (basic_string<>::_Rep::
+ _M_set_length_and_sharable): Do not write the empty rep.
+ (basic_string<>::erase(iterator, iterator)): Likewise,
+ move out of line...
+ * include/bits/basic_string.tcc: ... here.
+
+2009-06-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * testsuite/util/testsuite_common_types.h (bitwise_operators,
+ bitwise_assignment_operators): Initialize a and b.
+ (struct has_bitwise_operators): Do not call the latter.
+ * testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Adjust
+ dg-error line numbers.
+ * testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
+ * testsuite/29_atomics/atomic/cons/assign_neg.cc: Likewise.
+ * testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise.
+
+2009-06-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * testsuite/23_containers/list/invalidation/1.cc: Mark test as
+ possibly unused.
+ * testsuite/23_containers/list/invalidation/2.cc: Likewise.
+ * testsuite/23_containers/list/invalidation/3.cc: Likewise.
+ * testsuite/23_containers/list/invalidation/4.cc: Likewise.
+
+2009-06-21 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/std/future: New.
+ * include/Makefile.am: Add.
+ * include/Makefile.in: Regenerate.
+ * src/future.cc: New.
+ * src/Makefile.am: Add.
+ * src/Makefile.in: Regenerate.
+ * config/abi/pre/gnu.ver: Add export.
+ * testsuite/30_threads/headers/future/std_c++0x_neg.cc: New.
+ * testsuite/30_threads/headers/future/types_std_c++0x.cc: New.
+ * testsuite/30_threads/packaged_task/cons/1.cc: New.
+ * testsuite/30_threads/packaged_task/cons/2.cc: New.
+ * testsuite/30_threads/packaged_task/cons/assign_neg.cc: New.
+ * testsuite/30_threads/packaged_task/cons/copy_neg.cc: New.
+ * testsuite/30_threads/packaged_task/cons/move_assign.cc: New.
+ * testsuite/30_threads/packaged_task/cons/move.cc: New.
+ * testsuite/30_threads/packaged_task/members/boolconv.cc: New.
+ * testsuite/30_threads/packaged_task/members/get_future.cc: New.
+ * testsuite/30_threads/packaged_task/members/get_future2.cc: New.
+ * testsuite/30_threads/packaged_task/members/invoke.cc: New.
+ * testsuite/30_threads/packaged_task/members/invoke2.cc: New.
+ * testsuite/30_threads/packaged_task/members/invoke3.cc: New.
+ * testsuite/30_threads/packaged_task/members/invoke4.cc: New.
+ * testsuite/30_threads/packaged_task/members/invoke5.cc: New.
+ * testsuite/30_threads/packaged_task/members/reset.cc: New.
+ * testsuite/30_threads/packaged_task/members/reset2.cc: New.
+ * testsuite/30_threads/packaged_task/members/swap.cc: New.
+ * testsuite/30_threads/packaged_task/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/30_threads/promise/cons/1.cc: New.
+ * testsuite/30_threads/promise/cons/assign_neg.cc: New.
+ * testsuite/30_threads/promise/cons/copy_neg.cc: New.
+ * testsuite/30_threads/promise/cons/move_assign.cc: New.
+ * testsuite/30_threads/promise/cons/move.cc: New.
+ * testsuite/30_threads/promise/members/get_future.cc: New.
+ * testsuite/30_threads/promise/members/get_future2.cc: New.
+ * testsuite/30_threads/promise/members/set_exception.cc: New.
+ * testsuite/30_threads/promise/members/set_exception2.cc: New.
+ * testsuite/30_threads/promise/members/set_value.cc: New.
+ * testsuite/30_threads/promise/members/set_value2.cc: New.
+ * testsuite/30_threads/promise/members/set_value3.cc: New.
+ * testsuite/30_threads/promise/members/swap.cc: New.
+ * testsuite/30_threads/promise/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/30_threads/shared_future/cons/assign_neg.cc: New.
+ * testsuite/30_threads/shared_future/cons/copy.cc: New.
+ * testsuite/30_threads/shared_future/cons/default_neg.cc: New.
+ * testsuite/30_threads/shared_future/cons/move.cc: New.
+ * testsuite/30_threads/shared_future/members/get.cc: New.
+ * testsuite/30_threads/shared_future/members/get2.cc: New.
+ * testsuite/30_threads/shared_future/members/has_exception.cc: New.
+ * testsuite/30_threads/shared_future/members/has_value.cc: New.
+ * testsuite/30_threads/shared_future/members/is_ready.cc: New.
+ * testsuite/30_threads/shared_future/members/wait.cc: New.
+ * testsuite/30_threads/shared_future/members/wait_for.cc: New.
+ * testsuite/30_threads/shared_future/members/wait_until.cc: New.
+ * testsuite/30_threads/shared_future/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/30_threads/unique_future/cons/assign_neg.cc: New.
+ * testsuite/30_threads/unique_future/cons/copy_neg.cc: New.
+ * testsuite/30_threads/unique_future/cons/default_neg.cc: New.
+ * testsuite/30_threads/unique_future/cons/move.cc: New.
+ * testsuite/30_threads/unique_future/members/get.cc: New.
+ * testsuite/30_threads/unique_future/members/get2.cc: New.
+ * testsuite/30_threads/unique_future/members/has_exception.cc: New.
+ * testsuite/30_threads/unique_future/members/has_value.cc: New.
+ * testsuite/30_threads/unique_future/members/is_ready.cc: New.
+ * testsuite/30_threads/unique_future/members/wait.cc: New.
+ * testsuite/30_threads/unique_future/members/wait_for.cc: New.
+ * testsuite/30_threads/unique_future/members/wait_until.cc: New.
+ * testsuite/30_threads/unique_future/requirements/
+ explicit_instantiation.cc: New.
+ * testsuite/performance/30_threads/future/polling.cc: New.
+
+2009-06-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * Revert last Change.
+
+2009-06-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/40497
+ * include/bits/stl_iterator_base_funcs.h (next, prev): Fix the
+ signature per the current C++1x draft (N2857).
+ * testsuite/24_iterators/operations/40497.cc: Add.
+
+2009-06-19 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/random.h (_Adaptor): Simplify for _DInputType always
+ a floating point type.
+ (uniform_int_distribution<>::uniform_int_distribution(_IntType,
+ _IntType)): Fix second default argument.
+ (uniform_int_distribution<>::_M_call): Remove.
+ (uniform_int_distribution<>::operator()(_UniformRandomNumberGenerator&,
+ const param_type&)): Only declare.
+ * include/bits/random.tcc (uniform_int_distribution<>::_M_call(
+ _UniformRandomNumberGenerator&, result_type, result_type, true_type):
+ Remove.
+ uniform_int_distribution<>::operator()(_UniformRandomNumberGenerator&,
+ const param_type&): Define here.
+ (geometric_distribution<>::operator()(_UniformRandomNumberGenerator&,
+ const param_type&), discrete_distribution<>::operator()
+ (_UniformRandomNumberGenerator&, const param_type&),
+ piecewise_constant_distribution<>::operator()
+ (_UniformRandomNumberGenerator&, const param_type&),
+ piecewise_linear_distribution<>::operator()
+ (_UniformRandomNumberGenerator&, const param_type&)): Use double as
+ the second template argument of _Adaptor.
+ * testsuite/26_numerics/random/uniform_int_distribution/cons/
+ default.cc: Adjust.
+
+2009-06-19 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/random.tcc (discrete_distribution<>::param_type::
+ param_type(size_t, double, double, _Func),
+ discrete_distribution<>::operator()(_UniformRandomNumberGenerator&,
+ const param_type&)): Tidy.
+ (piecewise_constant_distribution<>::param_type::_M_initialize):
+ Use reserve, fix.
+ (piecewise_constant_distribution<>::param_type::
+ param_type(initializer_list<>, _Func),
+ piecewise_constant_distribution<>::param_type::
+ param_type(size_t, _RealType, _RealType, _Func),
+ piecewise_linear_distribution<>::param_type::
+ param_type(initializer_list<>, _Func),
+ piecewise_linear_distribution<>::param_type::
+ param_type(size_t, _RealType, _RealType, _Func)): Use reserve, tidy.
+ (piecewise_constant_distribution<>::param_type::
+ param_type(_InputIteratorB, _InputIteratorB, _InputIteratorW),
+ piecewise_constant_distribution<>::
+ operator()(_UniformRandomNumberGenerator&, const param_type&),
+ piecewise_linear_distribution<>::
+ operator()(_UniformRandomNumberGenerator&, const param_type&)): Fix.
+ (operator>>(std::basic_istream<>&,
+ piecewise_constant_distribution<>&),
+ operator>>(std::basic_istream<>&, piecewise_linear_distribution<>&)):
+ Use reserve.
+ * include/bits/random.h: Minor cosmetic changes.
+
+2009-06-17 Benjamin Kosnik <bkoz@redhat.com>
+
+ * testsuite/23_containers/list/check_construct_destroy.h: New.
+ Move test logic here.
+ * testsuite/23_containers/list/moveable.h: Same.
+ * testsuite/23_containers/list/modifiers/insert/25288.h: Same.
+ * testsuite/23_containers/list/modifiers/1.h: Same.
+ * testsuite/23_containers/list/modifiers/2.h: Same.
+ * testsuite/23_containers/list/modifiers/3.h: Same.
+ * testsuite/23_containers/list/modifiers/swap/1.h: Same.
+ * testsuite/23_containers/list/modifiers/swap/2.h: Same.
+ * testsuite/23_containers/list/modifiers/swap/3.h: Same.
+ * testsuite/23_containers/list/operations/1.h: Same.
+ * testsuite/23_containers/list/operations/2.h: Same.
+ * testsuite/23_containers/list/operations/3.h: Same.
+ * testsuite/23_containers/list/operations/4.h: Same.
+ * testsuite/23_containers/list/operations/5.h: Same.
+ * testsuite/23_containers/list/capacity/1.h: Same.
+ * testsuite/23_containers/list/init-list.h: Same.
+ * testsuite/23_containers/list/cons/1.h: Same.
+ * testsuite/23_containers/list/cons/2.h: Same.
+ * testsuite/23_containers/list/cons/3.h: Same.
+ * testsuite/23_containers/list/cons/4.h: Same.
+ * testsuite/23_containers/list/cons/5.h: Same.
+ * testsuite/23_containers/list/cons/6.h: Same.
+ * testsuite/23_containers/list/cons/7.h: Same.
+ * testsuite/23_containers/list/cons/8.h: Same.
+ * testsuite/23_containers/list/cons/9.h: Same.
+ * testsuite/23_containers/list/cons/clear_allocator.h: Same.
+ * testsuite/23_containers/list/modifiers/insert/25288.cc: Include test
+ header.
+ * testsuite/23_containers/list/modifiers/1.cc: Same.
+ * testsuite/23_containers/list/modifiers/2.cc: Same.
+ * testsuite/23_containers/list/modifiers/3.cc: Same.
+ * testsuite/23_containers/list/modifiers/swap/1.cc: Same.
+ * testsuite/23_containers/list/modifiers/swap/2.cc: Same.
+ * testsuite/23_containers/list/modifiers/swap/3.cc: Same.
+ * testsuite/23_containers/list/operations/1.cc: Same.
+ * testsuite/23_containers/list/operations/2.cc: Same.
+ * testsuite/23_containers/list/operations/3.cc: Same.
+ * testsuite/23_containers/list/operations/4.cc: Same.
+ * testsuite/23_containers/list/operations/5.cc: Same.
+ * testsuite/23_containers/list/capacity/1.cc: Same.
+ * testsuite/23_containers/list/init-list.cc: Same.
+ * testsuite/23_containers/list/cons/1.cc: Same.
+ * testsuite/23_containers/list/cons/2.cc: Same.
+ * testsuite/23_containers/list/cons/3.cc: Same.
+ * testsuite/23_containers/list/cons/4.cc: Same.
+ * testsuite/23_containers/list/cons/5.cc: Same.
+ * testsuite/23_containers/list/cons/6.cc: Same.
+ * testsuite/23_containers/list/cons/7.cc: Same.
+ * testsuite/23_containers/list/cons/8.cc: Same.
+ * testsuite/23_containers/list/cons/9.cc: Same.
+ * testsuite/23_containers/list/cons/clear_allocator.cc: Same.
+ * testsuite/23_containers/list/check_construct_destroy.cc: Same.
+ * testsuite/23_containers/list/moveable.cc: Same.
+
+2009-06-17 Tom Tromey <tromey@redhat.com>
+
+ * python/hook.in: Do not fail when there is no current objfile.
+ Use os.path.normpath.
+
+2009-06-16 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * libsupc++/exception_ptr.h (exception_ptr::swap(exception_ptr&&)):
+ Remove.
+ (exception_ptr::operator=(exception_ptr&&)): Cast source to
+ rvalue-reference so that move constructor is called.
+ * testsuite/18_support/exception_ptr/move.cc: New.
+
+2009-06-16 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/std/thread (~thread(), operator=(thread&&)): Call terminate
+ if joinable.
+
+2009-06-15 Tom Tromey <tromey@redhat.com>
+
+ * python/libstdcxx/v6/printers.py (StdMapPrinter.__init__): Don't
+ set self.iter.
+ (StdMapPrinter.to_string): Make a new iterator.
+ (StdMapPrinter.children): Likewise.
+ (StdSetPrinter.__init__): Don't set self.iter.
+ (StdSetPrinter.to_string): Make a new iterator.
+ (StdSetPrinter.children): Likewise.
+
+2009-06-11 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/random.tcc
+ (negative_binomial_distribution<>::operator()
+ (_UniformRandomNumberGenerator&, const param_type&): Tweak to use a
+ class member gamma_distribution.
+ (negative_binomial_distribution<>::operator()
+ (_UniformRandomNumberGenerator&)): Implement out of line here.
+ (operator<<(basic_ostream<>&, negative_binomial_distribution<>),
+ operator>>(basic_ostream<>&, negative_binomial_distribution<>): Adjust.
+ (student_t_distribution<>::operator()
+ (_UniformRandomNumberGenerator&, const param_type&): Move inline,
+ simplify.
+ (operator<<(basic_ostream<>&, student_t_distribution<>),
+ operator>>(basic_ostream<>&, student_t_distribution<>): Adjust.
+ (chi_squared_distribution<>::operator()
+ (_UniformRandomNumberGenerator&, const param_type&): Move inline,
+ tweak to use a class member gamma_distribution.
+ (operator<<(basic_ostream<>&, chi_squared_distribution<>),
+ operator>>(basic_ostream<>&, chi_squared_distribution<>): Adjust.
+ (fisher_f_distribution<>::operator() (_UniformRandomNumberGenerator&,
+ const param_type&): Move inline, tweak to use class member
+ gamma_distributions.
+ (operator<<(basic_ostream<>&, fisher_f_distribution<>),
+ operator>>(basic_ostream<>&, fisher_f_distribution<>): Adjust.
+ * include/bits/random.h: Adjust, minor tweaks.
+
+2009-06-10 Tom Tromey <tromey@redhat.com>
+
+ * python/libstdcxx/v6/printers.py (lookup_function): Remove extra ';'.
+ (build_libstdcxx_dictionary): Accept shortened form of
+ basic_string names.
+ (StdStringPrinter.to_string): Remove reference to WideEncoding.
+
+2009-06-10 Tom Tromey <tromey@redhat.com>
+
+ PR libstdc++/40289:
+ * python/Makefile.in: Rebuild.
+ * python/hook.in: Compute module path relative to objfile.
+ * python/Makefile.am (pythondir): Redefine.
+ (gdb.py): Subst toolexeclibdir.
+ (install-data-local): Rewrite.
+
+2009-06-09 Benjamin Kosnik <bkoz@redhat.com>
+
+ * include/bits/move.h: Doxygen group fixes.
+
2009-06-08 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/random.tcc (gamma_distribution<>::operator()
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 240e7bcf09b..3a24dc9fb16 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -964,6 +964,9 @@ GLIBCXX_3.4.12 {
_ZSt27__set_once_functor_lock_ptrPSt11unique_lockISt5mutexE;
_ZSt16__get_once_mutexv;
+ # future
+ _ZSt15future_category;
+
} GLIBCXX_3.4.11;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/config/locale/gnu/c_locale.cc b/libstdc++-v3/config/locale/gnu/c_locale.cc
index 4864d25cd34..80ef9c740d2 100644
--- a/libstdc++-v3/config/locale/gnu/c_locale.cc
+++ b/libstdc++-v3/config/locale/gnu/c_locale.cc
@@ -155,7 +155,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__dup == __c_locale(0))
__throw_runtime_error(__N("locale::facet::_S_lc_ctype_c_locale "
"duplocale error"));
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__c_locale __changed = __newlocale(LC_CTYPE_MASK, __s, __dup);
+#else
+ __c_locale __changed = __newlocale(1 << LC_CTYPE, __s, __dup);
+#endif
if (__changed == __c_locale(0))
{
__freelocale(__dup);
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index 68ba288ece5..de7745a1286 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -103,6 +103,10 @@ case "${host_cpu}" in
hppa*)
try_cpu=hppa
;;
+ mep*)
+ EXTRA_CXX_FLAGS=-mm
+ try_cpu=generic
+ ;;
mips*)
try_cpu=mips
;;
diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in
index 8e09894d4f9..9c4b6c9bf51 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -590,6 +590,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
include/deque \
include/fstream \
include/functional \
+ include/future \
include/iomanip \
include/ios \
include/iosfwd \
@@ -1427,6 +1428,10 @@ PREDEFINED = __cplusplus \
_GLIBCXX_USE_WCHAR_T \
_GLIBCXX_USE_LONG_LONG \
_GLIBCXX_USE_C99_STDINT_TR1 \
+ _GLIBCXX_ATOMIC_BUILTINS_1 \
+ _GLIBCXX_ATOMIC_BUILTINS_2 \
+ _GLIBCXX_ATOMIC_BUILTINS_4 \
+ _GLIBCXX_ATOMIC_BUILTINS_8 \
_GLIBCXX_USE_SCHED_YIELD \
_GLIBCXX_USE_NANOSLEEP \
__glibcxx_function_requires=// \
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 6a9c4f09ed4..b0fc483f20b 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -38,6 +38,7 @@ std_headers = \
${std_srcdir}/forward_list \
${std_srcdir}/fstream \
${std_srcdir}/functional \
+ ${std_srcdir}/future \
${std_srcdir}/iomanip \
${std_srcdir}/ios \
${std_srcdir}/iosfwd \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 4ac2739cb43..bba451f7db6 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -304,6 +304,7 @@ std_headers = \
${std_srcdir}/forward_list \
${std_srcdir}/fstream \
${std_srcdir}/functional \
+ ${std_srcdir}/future \
${std_srcdir}/iomanip \
${std_srcdir}/ios \
${std_srcdir}/iosfwd \
diff --git a/libstdc++-v3/include/bits/atomic_0.h b/libstdc++-v3/include/bits/atomic_0.h
index 5d2631d76e9..a493ea66af9 100644
--- a/libstdc++-v3/include/bits/atomic_0.h
+++ b/libstdc++-v3/include/bits/atomic_0.h
@@ -119,17 +119,17 @@ namespace __atomic0
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
- __glibcxx_assert(__m == memory_order_acquire);
- __glibcxx_assert(__m == memory_order_acq_rel);
- __glibcxx_assert(__m == memory_order_consume);
+ __glibcxx_assert(__m != memory_order_acquire);
+ __glibcxx_assert(__m != memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_consume);
_ATOMIC_STORE_(this, __v, __m);
}
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
- __glibcxx_assert(__m == memory_order_release);
- __glibcxx_assert(__m == memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_release);
+ __glibcxx_assert(__m != memory_order_acq_rel);
return _ATOMIC_LOAD_(this, __m);
}
@@ -141,8 +141,8 @@ namespace __atomic0
compare_exchange_weak(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
- __glibcxx_assert(__m2 == memory_order_release);
- __glibcxx_assert(__m2 == memory_order_acq_rel);
+ __glibcxx_assert(__m2 != memory_order_release);
+ __glibcxx_assert(__m2 != memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
}
@@ -159,8 +159,8 @@ namespace __atomic0
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
- __glibcxx_assert(__m2 == memory_order_release);
- __glibcxx_assert(__m2 == memory_order_acq_rel);
+ __glibcxx_assert(__m2 != memory_order_release);
+ __glibcxx_assert(__m2 != memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
}
@@ -310,17 +310,17 @@ namespace __atomic0
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
- __glibcxx_assert(__m == memory_order_acquire);
- __glibcxx_assert(__m == memory_order_acq_rel);
- __glibcxx_assert(__m == memory_order_consume);
+ __glibcxx_assert(__m != memory_order_acquire);
+ __glibcxx_assert(__m != memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_consume);
_ATOMIC_STORE_(this, __i, __m);
}
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
{
- __glibcxx_assert(__m == memory_order_release);
- __glibcxx_assert(__m == memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_release);
+ __glibcxx_assert(__m != memory_order_acq_rel);
return _ATOMIC_LOAD_(this, __m);
}
@@ -333,8 +333,8 @@ namespace __atomic0
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
- __glibcxx_assert(__m2 == memory_order_release);
- __glibcxx_assert(__m2 == memory_order_acq_rel);
+ __glibcxx_assert(__m2 != memory_order_release);
+ __glibcxx_assert(__m2 != memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
}
@@ -351,8 +351,8 @@ namespace __atomic0
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
- __glibcxx_assert(__m2 == memory_order_release);
- __glibcxx_assert(__m2 == memory_order_acq_rel);
+ __glibcxx_assert(__m2 != memory_order_release);
+ __glibcxx_assert(__m2 != memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
}
diff --git a/libstdc++-v3/include/bits/atomic_2.h b/libstdc++-v3/include/bits/atomic_2.h
index c172767140f..8e8e7ff16f8 100644
--- a/libstdc++-v3/include/bits/atomic_2.h
+++ b/libstdc++-v3/include/bits/atomic_2.h
@@ -65,6 +65,10 @@ namespace __atomic2
void
clear(memory_order __m = memory_order_seq_cst) volatile
{
+ __glibcxx_assert(__m != memory_order_consume);
+ __glibcxx_assert(__m != memory_order_acquire);
+ __glibcxx_assert(__m != memory_order_acq_rel);
+
__sync_lock_release(&_M_i);
if (__m != memory_order_acquire && __m != memory_order_acq_rel)
__sync_synchronize();
@@ -93,9 +97,9 @@ namespace __atomic2
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
- __glibcxx_assert(__m == memory_order_acquire);
- __glibcxx_assert(__m == memory_order_acq_rel);
- __glibcxx_assert(__m == memory_order_consume);
+ __glibcxx_assert(__m != memory_order_acquire);
+ __glibcxx_assert(__m != memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_consume);
if (__m == memory_order_relaxed)
_M_i = __v;
@@ -111,8 +115,8 @@ namespace __atomic2
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
- __glibcxx_assert(__m == memory_order_release);
- __glibcxx_assert(__m == memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_release);
+ __glibcxx_assert(__m != memory_order_acq_rel);
__sync_synchronize();
void* __ret = _M_i;
@@ -144,8 +148,8 @@ namespace __atomic2
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
- __glibcxx_assert(__m2 == memory_order_release);
- __glibcxx_assert(__m2 == memory_order_acq_rel);
+ __glibcxx_assert(__m2 != memory_order_release);
+ __glibcxx_assert(__m2 != memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
void* __v1o = __v1;
@@ -284,9 +288,9 @@ namespace __atomic2
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
- __glibcxx_assert(__m == memory_order_acquire);
- __glibcxx_assert(__m == memory_order_acq_rel);
- __glibcxx_assert(__m == memory_order_consume);
+ __glibcxx_assert(__m != memory_order_acquire);
+ __glibcxx_assert(__m != memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_consume);
if (__m == memory_order_relaxed)
_M_i = __i;
@@ -302,8 +306,8 @@ namespace __atomic2
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
{
- __glibcxx_assert(__m == memory_order_release);
- __glibcxx_assert(__m == memory_order_acq_rel);
+ __glibcxx_assert(__m != memory_order_release);
+ __glibcxx_assert(__m != memory_order_acq_rel);
__sync_synchronize();
__integral_type __ret = _M_i;
@@ -336,8 +340,8 @@ namespace __atomic2
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
- __glibcxx_assert(__m2 == memory_order_release);
- __glibcxx_assert(__m2 == memory_order_acq_rel);
+ __glibcxx_assert(__m2 != memory_order_release);
+ __glibcxx_assert(__m2 != memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
__integral_type __i1o = __i1;
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 1e8300dabfa..085aea463b6 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -197,12 +197,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void
_M_set_length_and_sharable(size_type __n)
- {
- this->_M_set_sharable(); // One reference.
- this->_M_length = __n;
- traits_type::assign(this->_M_refdata()[__n], _S_terminal);
- // grrr. (per 21.3.4)
- // You cannot leave those LWG people alone for a second.
+ {
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
+ if (__builtin_expect(this != &_S_empty_rep(), false))
+#endif
+ {
+ this->_M_set_sharable(); // One reference.
+ this->_M_length = __n;
+ traits_type::assign(this->_M_refdata()[__n], _S_terminal);
+ // grrr. (per 21.3.4)
+ // You cannot leave those LWG people alone for a second.
+ }
}
_CharT*
@@ -1226,16 +1231,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* The value of the string doesn't change if an error is thrown.
*/
iterator
- erase(iterator __first, iterator __last)
- {
- _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
- && __last <= _M_iend());
- const size_type __pos = __first - _M_ibegin();
- _M_mutate(__pos, __last - __first, size_type(0));
- _M_rep()->_M_set_leaked();
- return iterator(_M_data() + __pos);
- }
-
+ erase(iterator __first, iterator __last);
+
/**
* @brief Replace characters with value from another string.
* @param pos Index of first character to replace.
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index ec771c66859..d450a4717de 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -386,6 +386,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _CharT, typename _Traits, typename _Alloc>
+ typename basic_string<_CharT, _Traits, _Alloc>::iterator
+ basic_string<_CharT, _Traits, _Alloc>::
+ erase(iterator __first, iterator __last)
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
+ && __last <= _M_iend());
+
+ // NB: This isn't just an optimization (bail out early when
+ // there is nothing to do, really), it's also a correctness
+ // issue vs MT, see libstdc++/40518.
+ const size_type __size = __last - __first;
+ if (__size)
+ {
+ const size_type __pos = __first - _M_ibegin();
+ _M_mutate(__pos, __size, size_type(0));
+ _M_rep()->_M_set_leaked();
+ return iterator(_M_data() + __pos);
+ }
+ else
+ return __first;
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
replace(size_type __pos, size_type __n1, const _CharT* __s,
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h
index ef86c4d1206..25773e13c48 100644
--- a/libstdc++-v3/include/bits/move.h
+++ b/libstdc++-v3/include/bits/move.h
@@ -39,18 +39,25 @@
_GLIBCXX_BEGIN_NAMESPACE(std)
- // 20.2.2, forward/move
+ /// identity
template<typename _Tp>
struct identity
{
typedef _Tp type;
};
+ /// forward
template<typename _Tp>
inline _Tp&&
forward(typename std::identity<_Tp>::type&& __t)
{ return __t; }
+ /**
+ * @brief Move a value.
+ * @ingroup mutating_algorithms
+ * @param __t A thing of arbitrary type.
+ * @return Same, moved.
+ */
template<typename _Tp>
inline typename std::remove_reference<_Tp>::type&&
move(_Tp&& __t)
@@ -67,8 +74,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @brief Swaps two values.
- * @param a A thing of arbitrary type.
- * @param b Another thing of arbitrary type.
+ * @ingroup mutating_algorithms
+ * @param __a A thing of arbitrary type.
+ * @param __b Another thing of arbitrary type.
* @return Nothing.
*/
template<typename _Tp>
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 8a21ae55da7..aa34fccf248 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -68,18 +68,15 @@ namespace std
struct _Shift<_UIntType, __w, true>
{ static const _UIntType __value = _UIntType(1) << __w; };
- template<typename _Tp, _Tp __a, _Tp __c, _Tp __m, bool>
+ template<typename _Tp, _Tp __m, _Tp __a, _Tp __c, bool>
struct _Mod;
// Dispatch based on modulus value to prevent divide-by-zero compile-time
// errors when m == 0.
- template<typename _Tp, _Tp __a, _Tp __c, _Tp __m>
+ template<typename _Tp, _Tp __m, _Tp __a = 1, _Tp __c = 0>
inline _Tp
__mod(_Tp __x)
- { return _Mod<_Tp, __a, __c, __m, __m == 0>::__calc(__x); }
-
- typedef __gnu_cxx::__conditional_type<(sizeof(unsigned) == 4),
- unsigned, unsigned long>::__type _UInt32Type;
+ { return _Mod<_Tp, __m, __a, __c, __m == 0>::__calc(__x); }
/*
* An adaptor class for converting the output of any Generator into
@@ -95,40 +92,23 @@ namespace std
_DInputType
min() const
- {
- if (is_integral<_DInputType>::value)
- return _M_g.min();
- else
- return _DInputType(0);
- }
+ { return _DInputType(0); }
_DInputType
max() const
- {
- if (is_integral<_DInputType>::value)
- return _M_g.max();
- else
- return _DInputType(1);
- }
+ { return _DInputType(1); }
/*
* Converts a value generated by the adapted random number generator
* into a value in the input domain for the dependent random number
* distribution.
- *
- * Because the type traits are compile time constants only the
- * appropriate clause of the if statements will actually be emitted
- * by the compiler.
*/
_DInputType
operator()()
{
- if (is_integral<_DInputType>::value)
- return _M_g();
- else
- return generate_canonical<_DInputType,
- numeric_limits<_DInputType>::digits,
- _Engine>(_M_g);
+ return std::generate_canonical<_DInputType,
+ std::numeric_limits<_DInputType>::digits,
+ _Engine>(_M_g);
}
private:
@@ -270,7 +250,7 @@ namespace std
result_type
operator()()
{
- _M_x = __detail::__mod<_UIntType, __a, __c, __m>(_M_x);
+ _M_x = __detail::__mod<_UIntType, __m, __a, __c>(_M_x);
return _M_x;
}
@@ -298,8 +278,7 @@ namespace std
* @returns __os.
*/
template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
- _UIntType1 __m1,
- typename _CharT, typename _Traits>
+ _UIntType1 __m1, typename _CharT, typename _Traits>
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>&,
const std::linear_congruential_engine<_UIntType1,
@@ -319,8 +298,7 @@ namespace std
* @returns __is.
*/
template<typename _UIntType1, _UIntType1 __a1, _UIntType1 __c1,
- _UIntType1 __m1,
- typename _CharT, typename _Traits>
+ _UIntType1 __m1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
std::linear_congruential_engine<_UIntType1, __a1,
@@ -380,7 +358,7 @@ namespace std
static_assert(__w >= __l,
"mersenne_twister_engine template arguments out of bounds");
static_assert(__w <=
- static_cast<size_t>(numeric_limits<_UIntType>::digits),
+ static_cast<size_t>(std::numeric_limits<_UIntType>::digits),
"mersenne_twister_engine template arguments out of bounds");
static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"mersenne_twister_engine template arguments out of bounds");
@@ -388,6 +366,10 @@ namespace std
"mersenne_twister_engine template arguments out of bounds");
static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"mersenne_twister_engine template arguments out of bounds");
+ static_assert(__d <= (__detail::_Shift<_UIntType, __w>::__value - 1),
+ "mersenne_twister_engine template arguments out of bounds");
+ static_assert(__f <= (__detail::_Shift<_UIntType, __w>::__value - 1),
+ "mersenne_twister_engine template arguments out of bounds");
public:
/** The type of the generated random value. */
@@ -406,7 +388,7 @@ namespace std
static const size_t tempering_t = __t;
static const result_type tempering_c = __c;
static const size_t tempering_l = __l;
- static const size_t initialization_multiplier = __f;
+ static const result_type initialization_multiplier = __f;
static const result_type default_seed = 5489u;
// constructors and member function
@@ -558,8 +540,9 @@ namespace std
{
__glibcxx_class_requires(_UIntType, _UnsignedIntegerConcept)
static_assert(__s > 0U && __r > __s
- && __w > 0U
- && __w <= static_cast<size_t>(numeric_limits<_UIntType>::digits),
+ && __w > 0U
+ && __w <= static_cast<size_t>
+ (std::numeric_limits<_UIntType>::digits),
"template arguments out of bounds"
" in subtract_with_carry_engine");
@@ -922,7 +905,8 @@ namespace std
{
static_assert(__w > 0U
&& __w <=
- static_cast<size_t>(numeric_limits<_UIntType>::digits),
+ static_cast<size_t>
+ (std::numeric_limits<_UIntType>::digits),
"template arguments out of bounds "
"in independent_bits_engine");
@@ -1366,11 +1350,11 @@ namespace std
typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>
ranlux24_base;
- typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
-
typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12>
ranlux48_base;
+ typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
+
typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
/**
@@ -1507,7 +1491,8 @@ namespace std
typedef uniform_int_distribution<_IntType> distribution_type;
explicit
- param_type(_IntType __a = 0, _IntType __b = 9)
+ param_type(_IntType __a = 0,
+ _IntType __b = std::numeric_limits<_IntType>::max())
: _M_a(__a), _M_b(__b)
{
_GLIBCXX_DEBUG_ASSERT(_M_a <= _M_b);
@@ -1531,7 +1516,8 @@ namespace std
* @brief Constructs a uniform distribution object.
*/
explicit
- uniform_int_distribution(_IntType __a = 0, _IntType __b = 9)
+ uniform_int_distribution(_IntType __a = 0,
+ _IntType __b = std::numeric_limits<_IntType>::max())
: _M_param(__a, __b)
{ }
@@ -1602,29 +1588,7 @@ namespace std
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- typedef typename _UniformRandomNumberGenerator::result_type
- _UResult_type;
- return _M_call(__urng, __p.a(), __p.b(),
- typename is_integral<_UResult_type>::type());
- }
-
- private:
- template<typename _UniformRandomNumberGenerator>
- result_type
- _M_call(_UniformRandomNumberGenerator& __urng,
- result_type __min, result_type __max, true_type);
-
- template<typename _UniformRandomNumberGenerator>
- result_type
- _M_call(_UniformRandomNumberGenerator& __urng,
- result_type __min, result_type __max, false_type)
- {
- return result_type((__urng() - __urng.min())
- / (__urng.max() - __urng.min())
- * (__max - __min + 1)) + __min;
- }
+ const param_type& __p);
param_type _M_param;
};
@@ -2078,7 +2042,7 @@ namespace std
private:
param_type _M_param;
- normal_distribution<result_type> _M_nd;
+ std::normal_distribution<result_type> _M_nd;
};
/**
@@ -2111,6 +2075,164 @@ namespace std
operator>>(std::basic_istream<_CharT, _Traits>&,
std::lognormal_distribution<_RealType>&);
+
+ /**
+ * @brief A gamma continuous distribution for random numbers.
+ *
+ * The formula for the gamma probability density function is
+ * @f$ p(x|\alpha,\beta) = \frac{1}{\beta\Gamma(\alpha)}
+ * (x/\beta)^{\alpha - 1} e^{-x/\beta} @f$.
+ */
+ template<typename _RealType = double>
+ class gamma_distribution
+ {
+ public:
+ /** The type of the range of the distribution. */
+ typedef _RealType result_type;
+ /** Parameter type. */
+ struct param_type
+ {
+ typedef gamma_distribution<_RealType> distribution_type;
+ friend class gamma_distribution<_RealType>;
+
+ explicit
+ param_type(_RealType __alpha_val = _RealType(1),
+ _RealType __beta_val = _RealType(1))
+ : _M_alpha(__alpha_val), _M_beta(__beta_val)
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_alpha > _RealType(0));
+ _M_initialize();
+ }
+
+ _RealType
+ alpha() const
+ { return _M_alpha; }
+
+ _RealType
+ beta() const
+ { return _M_beta; }
+
+ private:
+ void
+ _M_initialize();
+
+ _RealType _M_alpha;
+ _RealType _M_beta;
+
+ _RealType _M_malpha, _M_a2;
+ };
+
+ public:
+ /**
+ * @brief Constructs a gamma distribution with parameters
+ * @f$ \alpha @f$ and @f$ \beta @f$.
+ */
+ explicit
+ gamma_distribution(_RealType __alpha_val = _RealType(1),
+ _RealType __beta_val = _RealType(1))
+ : _M_param(__alpha_val, __beta_val), _M_nd()
+ { }
+
+ explicit
+ gamma_distribution(const param_type& __p)
+ : _M_param(__p), _M_nd()
+ { }
+
+ /**
+ * @brief Resets the distribution state.
+ */
+ void
+ reset()
+ { _M_nd.reset(); }
+
+ /**
+ * @brief Returns the @f$ \alpha @f$ of the distribution.
+ */
+ _RealType
+ alpha() const
+ { return _M_param.alpha(); }
+
+ /**
+ * @brief Returns the @f$ \beta @f$ of the distribution.
+ */
+ _RealType
+ beta() const
+ { return _M_param.beta(); }
+
+ /**
+ * @brief Returns the parameter set of the distribution.
+ */
+ param_type
+ param() const
+ { return _M_param; }
+
+ /**
+ * @brief Sets the parameter set of the distribution.
+ * @param __param The new parameter set of the distribution.
+ */
+ void
+ param(const param_type& __param)
+ { _M_param = __param; }
+
+ /**
+ * @brief Returns the greatest lower bound value of the distribution.
+ */
+ result_type
+ min() const
+ { return result_type(0); }
+
+ /**
+ * @brief Returns the least upper bound value of the distribution.
+ */
+ result_type
+ max() const
+ { return std::numeric_limits<result_type>::max(); }
+
+ template<typename _UniformRandomNumberGenerator>
+ result_type
+ operator()(_UniformRandomNumberGenerator& __urng)
+ { return this->operator()(__urng, this->param()); }
+
+ template<typename _UniformRandomNumberGenerator>
+ result_type
+ operator()(_UniformRandomNumberGenerator& __urng,
+ const param_type& __p);
+
+ private:
+ param_type _M_param;
+
+ std::normal_distribution<result_type> _M_nd;
+ };
+
+ /**
+ * @brief Inserts a %gamma_distribution random number distribution
+ * @p __x into the output stream @p __os.
+ *
+ * @param __os An output stream.
+ * @param __x A %gamma_distribution random number distribution.
+ *
+ * @returns The output stream with the state of @p __x inserted or in
+ * an error state.
+ */
+ template<typename _RealType, typename _CharT, typename _Traits>
+ std::basic_ostream<_CharT, _Traits>&
+ operator<<(std::basic_ostream<_CharT, _Traits>&,
+ const std::gamma_distribution<_RealType>&);
+
+ /**
+ * @brief Extracts a %gamma_distribution random number distribution
+ * @p __x from the input stream @p __is.
+ *
+ * @param __is An input stream.
+ * @param __x A %gamma_distribution random number generator engine.
+ *
+ * @returns The input stream with @p __x extracted or in an error state.
+ */
+ template<typename _RealType, typename _CharT, typename _Traits>
+ std::basic_istream<_CharT, _Traits>&
+ operator>>(std::basic_istream<_CharT, _Traits>&,
+ std::gamma_distribution<_RealType>&);
+
/**
* @brief A chi_squared_distribution random number distribution.
@@ -2144,12 +2266,12 @@ namespace std
explicit
chi_squared_distribution(_RealType __n = _RealType(1))
- : _M_param(__n)
+ : _M_param(__n), _M_gd(__n / 2)
{ }
explicit
chi_squared_distribution(const param_type& __p)
- : _M_param(__p)
+ : _M_param(__p), _M_gd(__p.n() / 2)
{ }
/**
@@ -2157,7 +2279,7 @@ namespace std
*/
void
reset()
- { }
+ { _M_gd.reset(); }
/**
*
@@ -2198,15 +2320,22 @@ namespace std
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->param()); }
+ { return 2 * _M_gd(__urng); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
+ const param_type& __p)
+ {
+ typedef typename std::gamma_distribution<result_type>::param_type
+ param_type;
+ return 2 * _M_gd(__urng, param_type(__p.n() / 2));
+ }
private:
param_type _M_param;
+
+ std::gamma_distribution<result_type> _M_gd;
};
/**
@@ -2420,12 +2549,12 @@ namespace std
explicit
fisher_f_distribution(_RealType __m = _RealType(1),
_RealType __n = _RealType(1))
- : _M_param(__m, __n)
+ : _M_param(__m, __n), _M_gd_x(__m / 2), _M_gd_y(__n / 2)
{ }
explicit
fisher_f_distribution(const param_type& __p)
- : _M_param(__p)
+ : _M_param(__p), _M_gd_x(__p.m() / 2), _M_gd_y(__p.n() / 2)
{ }
/**
@@ -2433,7 +2562,10 @@ namespace std
*/
void
reset()
- { }
+ {
+ _M_gd_x.reset();
+ _M_gd_y.reset();
+ }
/**
*
@@ -2478,15 +2610,23 @@ namespace std
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->param()); }
+ { return (_M_gd_x(__urng) * n()) / (_M_gd_y(__urng) * m()); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
+ const param_type& __p)
+ {
+ typedef typename std::gamma_distribution<result_type>::param_type
+ param_type;
+ return ((_M_gd_x(__urng, param_type(__p.m() / 2)) * n())
+ / (_M_gd_y(__urng, param_type(__p.n() / 2)) * m()));
+ }
private:
param_type _M_param;
+
+ std::gamma_distribution<result_type> _M_gd_x, _M_gd_y;
};
/**
@@ -2553,12 +2693,12 @@ namespace std
explicit
student_t_distribution(_RealType __n = _RealType(1))
- : _M_param(__n), _M_nd()
+ : _M_param(__n), _M_nd(), _M_gd(__n / 2, 2)
{ }
explicit
student_t_distribution(const param_type& __p)
- : _M_param(__p), _M_nd()
+ : _M_param(__p), _M_nd(), _M_gd(__p.n() / 2, 2)
{ }
/**
@@ -2566,7 +2706,10 @@ namespace std
*/
void
reset()
- { _M_nd.reset(); }
+ {
+ _M_nd.reset();
+ _M_gd.reset();
+ }
/**
*
@@ -2606,18 +2749,26 @@ namespace std
template<typename _UniformRandomNumberGenerator>
result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->param()); }
+ operator()(_UniformRandomNumberGenerator& __urng)
+ { return _M_nd(__urng) * std::sqrt(n() / _M_gd(__urng)); }
template<typename _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
+ const param_type& __p)
+ {
+ typedef typename std::gamma_distribution<result_type>::param_type
+ param_type;
+
+ const result_type __g = _M_gd(__urng, param_type(__p.n() / 2, 2));
+ return _M_nd(__urng) * std::sqrt(__p.n() / __g);
+ }
private:
param_type _M_param;
- normal_distribution<result_type> _M_nd;
+ std::normal_distribution<result_type> _M_nd;
+ std::gamma_distribution<result_type> _M_gd;
};
/**
@@ -2977,7 +3128,7 @@ namespace std
param_type _M_param;
// NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined.
- normal_distribution<double> _M_nd;
+ std::normal_distribution<double> _M_nd;
};
@@ -3166,12 +3317,12 @@ namespace std
explicit
negative_binomial_distribution(_IntType __k = 1, double __p = 0.5)
- : _M_param(__k, __p)
+ : _M_param(__k, __p), _M_gd(__k, __p / (1.0 - __p))
{ }
explicit
negative_binomial_distribution(const param_type& __p)
- : _M_param(__p)
+ : _M_param(__p), _M_gd(__p.k(), __p.p() / (1.0 - __p.p()))
{ }
/**
@@ -3179,7 +3330,7 @@ namespace std
*/
void
reset()
- { }
+ { _M_gd.reset(); }
/**
* @brief Return the @f$ k @f$ parameter of the distribution.
@@ -3226,8 +3377,7 @@ namespace std
template<typename _UniformRandomNumberGenerator>
result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->param()); }
+ operator()(_UniformRandomNumberGenerator& __urng);
template<typename _UniformRandomNumberGenerator>
result_type
@@ -3236,6 +3386,8 @@ namespace std
private:
param_type _M_param;
+
+ std::gamma_distribution<double> _M_gd;
};
/**
@@ -3421,7 +3573,7 @@ namespace std
param_type _M_param;
// NB: Unused when _GLIBCXX_USE_C99_MATH_TR1 is undefined.
- normal_distribution<double> _M_nd;
+ std::normal_distribution<double> _M_nd;
};
/**
@@ -3575,164 +3727,6 @@ namespace std
/**
- * @brief A gamma continuous distribution for random numbers.
- *
- * The formula for the gamma probability density function is
- * @f$ p(x|\alpha,\beta) = \frac{1}{\beta\Gamma(\alpha)}
- * (x/\beta)^{\alpha - 1} e^{-x/\beta} @f$.
- */
- template<typename _RealType = double>
- class gamma_distribution
- {
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef gamma_distribution<_RealType> distribution_type;
- friend class gamma_distribution<_RealType>;
-
- explicit
- param_type(_RealType __alpha_val = _RealType(1),
- _RealType __beta_val = _RealType(1))
- : _M_alpha(__alpha_val), _M_beta(__beta_val)
- {
- _GLIBCXX_DEBUG_ASSERT(_M_alpha > _RealType(0));
- _M_initialize();
- }
-
- _RealType
- alpha() const
- { return _M_alpha; }
-
- _RealType
- beta() const
- { return _M_beta; }
-
- private:
- void
- _M_initialize();
-
- _RealType _M_alpha;
- _RealType _M_beta;
-
- _RealType _M_malpha, _M_a2;
- };
-
- public:
- /**
- * @brief Constructs a gamma distribution with parameters
- * @f$ \alpha @f$ and @f$ \beta @f$.
- */
- explicit
- gamma_distribution(_RealType __alpha_val = _RealType(1),
- _RealType __beta_val = _RealType(1))
- : _M_param(__alpha_val, __beta_val), _M_nd()
- { }
-
- explicit
- gamma_distribution(const param_type& __p)
- : _M_param(__p), _M_nd()
- { }
-
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { _M_nd.reset(); }
-
- /**
- * @brief Returns the @f$ \alpha @f$ of the distribution.
- */
- _RealType
- alpha() const
- { return _M_param.alpha(); }
-
- /**
- * @brief Returns the @f$ \beta @f$ of the distribution.
- */
- _RealType
- beta() const
- { return _M_param.beta(); }
-
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
-
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
-
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return result_type(0); }
-
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
-
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->param()); }
-
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
-
- private:
- param_type _M_param;
-
- normal_distribution<result_type> _M_nd;
- };
-
- /**
- * @brief Inserts a %gamma_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %gamma_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType, typename _CharT, typename _Traits>
- std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const std::gamma_distribution<_RealType>&);
-
- /**
- * @brief Extracts a %gamma_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %gamma_distribution random number generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType, typename _CharT, typename _Traits>
- std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- std::gamma_distribution<_RealType>&);
-
-
- /**
* @brief A weibull_distribution random number distribution.
*
* The formula for the normal probability density function is
@@ -4078,8 +4072,8 @@ namespace std
: _M_param(__wbegin, __wend)
{ }
- discrete_distribution(initializer_list<double> __wil)
- : _M_param(__wil)
+ discrete_distribution(initializer_list<double> __wl)
+ : _M_param(__wl)
{ }
template<typename _Func>
@@ -4210,7 +4204,7 @@ namespace std
_InputIteratorW __wbegin);
template<typename _Func>
- param_type(initializer_list<_RealType> __bil, _Func __fw);
+ param_type(initializer_list<_RealType> __bi, _Func __fw);
template<typename _Func>
param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
@@ -4246,9 +4240,9 @@ namespace std
{ }
template<typename _Func>
- piecewise_constant_distribution(initializer_list<_RealType> __bil,
+ piecewise_constant_distribution(initializer_list<_RealType> __bl,
_Func __fw)
- : _M_param(__bil, __fw)
+ : _M_param(__bl, __fw)
{ }
template<typename _Func>
@@ -4378,7 +4372,9 @@ namespace std
typedef piecewise_linear_distribution<_RealType> distribution_type;
friend class piecewise_linear_distribution<_RealType>;
- param_type();
+ param_type()
+ : _M_int(), _M_den(), _M_cp(), _M_m()
+ { _M_initialize(); }
template<typename _InputIteratorB, typename _InputIteratorW>
param_type(_InputIteratorB __bfirst,
@@ -4386,7 +4382,7 @@ namespace std
_InputIteratorW __wbegin);
template<typename _Func>
- param_type(initializer_list<_RealType> __bil, _Func __fw);
+ param_type(initializer_list<_RealType> __bl, _Func __fw);
template<typename _Func>
param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
@@ -4423,9 +4419,9 @@ namespace std
{ }
template<typename _Func>
- piecewise_linear_distribution(initializer_list<_RealType> __bil,
+ piecewise_linear_distribution(initializer_list<_RealType> __bl,
_Func __fw)
- : _M_param(__bil, __fw)
+ : _M_param(__bl, __fw)
{ }
template<typename _Func>
diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc
index b933f6d3dfc..e4c39612b7f 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -45,7 +45,7 @@ namespace std
//
// Preconditions: a > 0, m > 0.
//
- template<typename _Tp, _Tp __a, _Tp __c, _Tp __m, bool>
+ template<typename _Tp, _Tp __m, _Tp __a, _Tp __c, bool>
struct _Mod
{
static _Tp
@@ -80,8 +80,8 @@ namespace std
// Special case for m == 0 -- use unsigned integer overflow as modulo
// operator.
- template<typename _Tp, _Tp __a, _Tp __c, _Tp __m>
- struct _Mod<_Tp, __a, __c, __m, true>
+ template<typename _Tp, _Tp __m, _Tp __a, _Tp __c>
+ struct _Mod<_Tp, __m, __a, __c, true>
{
static _Tp
__calc(_Tp __x)
@@ -98,11 +98,11 @@ namespace std
linear_congruential_engine<_UIntType, __a, __c, __m>::
seed(result_type __s)
{
- if ((__detail::__mod<_UIntType, 1U, 0U, __m>(__c) == 0U)
- && (__detail::__mod<_UIntType, 1U, 0U, __m>(__s) == 0U))
- _M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(1U);
+ if ((__detail::__mod<_UIntType, __m>(__c) == 0)
+ && (__detail::__mod<_UIntType, __m>(__s) == 0))
+ _M_x = 1;
else
- _M_x = __detail::__mod<_UIntType, 1U, 0U, __m>(__s);
+ _M_x = __detail::__mod<_UIntType, __m>(__s);
}
/**
@@ -116,10 +116,10 @@ namespace std
const _UIntType __k0 = __m == 0 ? std::numeric_limits<_UIntType>::digits
: std::__lg(__m);
const _UIntType __k = (__k0 + 31) / 32;
- _UIntType __arr[__k + 3];
+ uint_least32_t __arr[__k + 3];
__q.generate(__arr + 0, __arr + __k + 3);
- _UIntType __factor = 1U;
- _UIntType __sum = 0U;
+ _UIntType __factor = 1u;
+ _UIntType __sum = 0u;
for (size_t __j = 0; __j < __k; ++__j)
{
__sum += __arr[__j + 3] * __factor;
@@ -179,7 +179,7 @@ namespace std
__s, __b, __t, __c, __l, __f>::
seed(result_type __sd)
{
- _M_x[0] = __detail::__mod<_UIntType, 1, 0,
+ _M_x[0] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sd);
for (size_t __i = 1; __i < state_size; ++__i)
@@ -187,8 +187,8 @@ namespace std
_UIntType __x = _M_x[__i - 1];
__x ^= __x >> (__w - 2);
__x *= __f;
- __x += __i;
- _M_x[__i] = __detail::__mod<_UIntType, 1, 0,
+ __x += __detail::__mod<_UIntType, __n>(__i);
+ _M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__x);
}
_M_p = state_size;
@@ -206,35 +206,35 @@ namespace std
{
const _UIntType __upper_mask = (~_UIntType()) << __r;
const size_t __k = (__w + 31) / 32;
- _UIntType __arr[__k * __n];
- __q.generate(__arr + 0, __arr + __k * __n);
+ uint_least32_t __arr[__n * __k];
+ __q.generate(__arr + 0, __arr + __n * __k);
bool __zero = true;
for (size_t __i = 0; __i < state_size; ++__i)
{
- _UIntType __factor = 1U;
- _UIntType __sum = 0U;
+ _UIntType __factor = 1u;
+ _UIntType __sum = 0u;
for (size_t __j = 0; __j < __k; ++__j)
{
- __sum += __arr[__i * __k + __j] * __factor;
+ __sum += __arr[__k * __i + __j] * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
- _M_x[__i] = __detail::__mod<_UIntType, 1U, 0U,
- __detail::_Shift<_UIntType, __w>::__value>(__sum);
+ _M_x[__i] = __detail::__mod<_UIntType,
+ __detail::_Shift<_UIntType, __w>::__value>(__sum);
if (__zero)
{
if (__i == 0)
{
- if ((_M_x[0] & __upper_mask) != 0U)
+ if ((_M_x[0] & __upper_mask) != 0u)
__zero = false;
}
- else if (_M_x[__i] != 0U)
+ else if (_M_x[__i] != 0u)
__zero = false;
}
}
if (__zero)
- _M_x[0] = __detail::_Shift<_UIntType, __w - 1U>::__value;
+ _M_x[0] = __detail::_Shift<_UIntType, __w - 1>::__value;
}
template<typename _UIntType, size_t __w,
@@ -345,26 +345,23 @@ namespace std
subtract_with_carry_engine<_UIntType, __w, __s, __r>::
seed(result_type __value)
{
- if (__value == 0)
- __value = default_seed;
-
- std::linear_congruential_engine<result_type, 40014U, 0U, 2147483563U>
- __lcg(__value);
+ std::linear_congruential_engine<result_type, 40014u, 0u, 2147483563u>
+ __lcg(__value == 0u ? default_seed : __value);
- // I hope this is right. The "10000" tests work for the ranluxen.
- const size_t __n = (word_size + 31) / 32;
+ const size_t __n = (__w + 31) / 32;
for (size_t __i = 0; __i < long_lag; ++__i)
{
- _UIntType __sum = 0U;
- _UIntType __factor = 1U;
+ _UIntType __sum = 0u;
+ _UIntType __factor = 1u;
for (size_t __j = 0; __j < __n; ++__j)
{
- __sum += __detail::__mod<__detail::_UInt32Type, 1, 0, 0>
+ __sum += __detail::__mod<uint_least32_t,
+ __detail::_Shift<uint_least32_t, 32>::__value>
(__lcg()) * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
- _M_x[__i] = __detail::__mod<_UIntType, 1, 0,
+ _M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sum);
}
_M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
@@ -376,21 +373,20 @@ namespace std
subtract_with_carry_engine<_UIntType, __w, __s, __r>::
seed(seed_seq& __q)
{
- const size_t __n = (word_size + 31) / 32;
- _UIntType __arr[long_lag + __n];
- __q.generate(__arr + 0, __arr + long_lag + __n);
+ const size_t __k = (__w + 31) / 32;
+ uint_least32_t __arr[__r * __k];
+ __q.generate(__arr + 0, __arr + __r * __k);
for (size_t __i = 0; __i < long_lag; ++__i)
{
- _UIntType __sum = 0U;
- _UIntType __factor = 1U;
- for (size_t __j = 0; __j < __n; ++__j)
+ _UIntType __sum = 0u;
+ _UIntType __factor = 1u;
+ for (size_t __j = 0; __j < __k; ++__j)
{
- __sum += __detail::__mod<__detail::_UInt32Type, 1, 0, 0>
- (__arr[__i * __n + __j]) * __factor;
+ __sum += __arr[__k * __i + __j] * __factor;
__factor *= __detail::_Shift<_UIntType, 32>::__value;
}
- _M_x[__i] = __detail::__mod<_UIntType, 1, 0,
+ _M_x[__i] = __detail::__mod<_UIntType,
__detail::_Shift<_UIntType, __w>::__value>(__sum);
}
_M_carry = (_M_x[long_lag - 1] == 0) ? 1 : 0;
@@ -644,13 +640,13 @@ namespace std
template<typename _UniformRandomNumberGenerator>
typename uniform_int_distribution<_IntType>::result_type
uniform_int_distribution<_IntType>::
- _M_call(_UniformRandomNumberGenerator& __urng,
- result_type __min, result_type __max, true_type)
+ operator()(_UniformRandomNumberGenerator& __urng,
+ const param_type& __param)
{
// XXX Must be fixed to work well for *arbitrary* __urng.max(),
- // __urng.min(), __max, __min. Currently works fine only in the
- // most common case __urng.max() - __urng.min() >= __max - __min,
- // with __urng.max() > __urng.min() >= 0.
+ // __urng.min(), __param.b(), __param.a(). Currently works fine only
+ // in the most common case __urng.max() - __urng.min() >=
+ // __param.b() - __param.a(), with __urng.max() > __urng.min() >= 0.
typedef typename __gnu_cxx::__add_unsigned<typename
_UniformRandomNumberGenerator::result_type>::__type __urntype;
typedef typename __gnu_cxx::__add_unsigned<result_type>::__type
@@ -664,14 +660,14 @@ namespace std
const __urntype __urnmin = __urng.min();
const __urntype __urnmax = __urng.max();
const __urntype __urnrange = __urnmax - __urnmin;
- const __uctype __urange = __max - __min;
+ const __uctype __urange = __param.b() - __param.a();
const __uctype __udenom = (__urnrange <= __urange
? 1 : __urnrange / (__urange + 1));
do
__ret = (__urntype(__urng()) - __urnmin) / __udenom;
- while (__ret > __max - __min);
+ while (__ret > __param.b() - __param.a());
- return __ret + __min;
+ return __ret + __param.a();
}
template<typename _IntType, typename _CharT, typename _Traits>
@@ -799,7 +795,7 @@ namespace std
// The largest _RealType convertible to _IntType.
const double __thr =
std::numeric_limits<_IntType>::max() + __naf;
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
double __cand;
@@ -854,6 +850,20 @@ namespace std
return __is;
}
+
+ template<typename _IntType>
+ template<typename _UniformRandomNumberGenerator>
+ typename negative_binomial_distribution<_IntType>::result_type
+ negative_binomial_distribution<_IntType>::
+ operator()(_UniformRandomNumberGenerator& __urng)
+ {
+ const double __y = _M_gd(__urng);
+
+ // XXX Is the constructor too slow?
+ std::poisson_distribution<result_type> __poisson(__y);
+ return __poisson(__urng);
+ }
+
template<typename _IntType>
template<typename _UniformRandomNumberGenerator>
typename negative_binomial_distribution<_IntType>::result_type
@@ -861,11 +871,13 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __p)
{
- gamma_distribution<> __gamma(__p.k(), 1.0);
- double __x = __gamma(__urng);
+ typedef typename std::gamma_distribution<result_type>::param_type
+ param_type;
+
+ const double __y =
+ _M_gd(__urng, param_type(__p.k(), __p.p() / (1.0 - __p.p())));
- poisson_distribution<result_type> __poisson(__x * __p.p()
- / (1.0 - __p.p()));
+ std::poisson_distribution<result_type> __poisson(__y);
return __poisson(__urng);
}
@@ -885,7 +897,8 @@ namespace std
__os.fill(__os.widen(' '));
__os.precision(std::numeric_limits<double>::digits10 + 1);
- __os << __x.k() << __space << __x.p();
+ __os << __x.k() << __space << __x.p()
+ << __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
@@ -906,7 +919,7 @@ namespace std
_IntType __k;
double __p;
- __is >> __k >> __p;
+ __is >> __k >> __p >> __x._M_gd;
__x.param(typename negative_binomial_distribution<_IntType>::
param_type(__k, __p));
@@ -1538,17 +1551,6 @@ namespace std
}
- template<typename _RealType>
- template<typename _UniformRandomNumberGenerator>
- typename chi_squared_distribution<_RealType>::result_type
- chi_squared_distribution<_RealType>::
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- gamma_distribution<_RealType> __gamma(__p.n() / 2, 1.0);
- return 2 * __gamma(__urng);
- }
-
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
@@ -1565,7 +1567,7 @@ namespace std
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::digits10 + 1);
- __os << __x.n();
+ __os << __x.n() << __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
@@ -1585,7 +1587,7 @@ namespace std
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __n;
- __is >> __n;
+ __is >> __n >> __x._M_gd;
__x.param(typename chi_squared_distribution<_RealType>::
param_type(__n));
@@ -1657,23 +1659,6 @@ namespace std
}
- template<typename _RealType>
- template<typename _UniformRandomNumberGenerator>
- typename fisher_f_distribution<_RealType>::result_type
- fisher_f_distribution<_RealType>::
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- gamma_distribution<_RealType> __gamma;
- _RealType __ym = __gamma(__urng,
- typename gamma_distribution<_RealType>::param_type(__p.m() / 2, 2));
-
- _RealType __yn = __gamma(__urng,
- typename gamma_distribution<_RealType>::param_type(__p.n() / 2, 2));
-
- return (__ym * __p.n()) / (__yn * __p.m());
- }
-
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
@@ -1690,7 +1675,8 @@ namespace std
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::digits10 + 1);
- __os << __x.m() << __space << __x.n();
+ __os << __x.m() << __space << __x.n()
+ << __space << __x._M_gd_x << __space << __x._M_gd_y;
__os.flags(__flags);
__os.fill(__fill);
@@ -1710,7 +1696,7 @@ namespace std
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __m, __n;
- __is >> __m >> __n;
+ __is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y;
__x.param(typename fisher_f_distribution<_RealType>::
param_type(__m, __n));
@@ -1719,43 +1705,6 @@ namespace std
}
- template<typename _RealType>
- template<typename _UniformRandomNumberGenerator>
- typename student_t_distribution<_RealType>::result_type
- student_t_distribution<_RealType>::
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __param)
- {
- if (__param.n() <= 2.0)
- {
- _RealType __y1 = _M_nd(__urng);
- chi_squared_distribution<_RealType> __chisq(__param.n());
- _RealType __y2 = __chisq(__urng);
-
- return __y1 / std::sqrt(__y2 / __param.n());
- }
- else
- {
- _RealType __y1, __y2, __z;
- exponential_distribution<_RealType>
- __exponential(1.0 / (__param.n() / 2.0 - 1.0));
-
- do
- {
- __y1 = _M_nd(__urng);
- __y2 = __exponential(__urng);
-
- __z = __y1 * __y1 / (__param.n() - 2.0);
- }
- while (1.0 - __z < 0.0 || std::exp(-__y2 - __z) > (1.0 - __z));
-
- // Note that there is a typo in Knuth's formula, the line below
- // is taken from the original paper of Marsaglia, Mathematics of
- // Computation, 34 (1980), p 234-256
- return __y1 / std::sqrt((1.0 - 2.0 / __param.n()) * (1.0 - __z));
- }
- }
-
template<typename _RealType, typename _CharT, typename _Traits>
std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
@@ -1772,7 +1721,7 @@ namespace std
__os.fill(__space);
__os.precision(std::numeric_limits<_RealType>::digits10 + 1);
- __os << __x.n() << __space << __x._M_nd;
+ __os << __x.n() << __space << __x._M_nd << __space << __x._M_gd;
__os.flags(__flags);
__os.fill(__fill);
@@ -1792,7 +1741,7 @@ namespace std
__is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __n;
- __is >> __n >> __x._M_nd;
+ __is >> __n >> __x._M_nd >> __x._M_gd;
__x.param(typename student_t_distribution<_RealType>::param_type(__n));
__is.flags(__flags);
@@ -2032,30 +1981,31 @@ namespace std
return;
}
- double __sum = std::accumulate(_M_prob.begin(), _M_prob.end(), 0.0);
- // Now normalize the densities.
+ const double __sum = std::accumulate(_M_prob.begin(),
+ _M_prob.end(), 0.0);
+ // Now normalize the probabilites.
std::transform(_M_prob.begin(), _M_prob.end(), _M_prob.begin(),
std::bind2nd(std::divides<double>(), __sum));
- // Accumulate partial sums.
+ // Accumulate partial sums.
+ _M_cp.reserve(_M_prob.size());
std::partial_sum(_M_prob.begin(), _M_prob.end(),
std::back_inserter(_M_cp));
- // Make sure the last cumulative probablility is one.
+ // Make sure the last cumulative probability is one.
_M_cp[_M_cp.size() - 1] = 1.0;
}
template<typename _IntType>
template<typename _Func>
discrete_distribution<_IntType>::param_type::
- param_type(size_t __nw, double __xmin, double __xmax,
- _Func __fw)
+ param_type(size_t __nw, double __xmin, double __xmax, _Func __fw)
: _M_prob(), _M_cp()
{
- for (size_t __i = 0; __i < __nw; ++__i)
- {
- const double __x = ((__nw - __i - 0.5) * __xmin
- + (__i + 0.5) * __xmax) / __nw;
- _M_prob.push_back(__fw(__x));
- }
+ const size_t __n = __nw == 0 ? 1 : __nw;
+ const double __delta = (__xmax - __xmin) / __n;
+
+ _M_prob.reserve(__n);
+ for (size_t __k = 0; __k < __nw; ++__k)
+ _M_prob.push_back(__fw(__xmin + __k * __delta + 0.5 * __delta));
_M_initialize();
}
@@ -2067,17 +2017,14 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
- if (__pos == __param._M_cp.end())
- return 0;
- const size_t __i = __pos - __param._M_cp.begin();
- return __i;
+ return __pos - __param._M_cp.begin();
}
template<typename _IntType, typename _CharT, typename _Traits>
@@ -2122,6 +2069,7 @@ namespace std
__is >> __n;
std::vector<double> __prob_vec;
+ __prob_vec.reserve(__n);
for (; __n != 0; --__n)
{
double __prob;
@@ -2145,6 +2093,7 @@ namespace std
if (_M_int.size() < 2)
{
_M_int.clear();
+ _M_int.reserve(2);
_M_int.push_back(_RealType(0));
_M_int.push_back(_RealType(1));
@@ -2154,21 +2103,21 @@ namespace std
return;
}
- double __sum = 0.0;
- for (size_t __i = 0; __i < _M_den.size(); ++__i)
- {
- __sum += _M_den[__i] * (_M_int[__i + 1] - _M_int[__i]);
- _M_cp.push_back(__sum);
- }
+ const double __sum = std::accumulate(_M_den.begin(),
+ _M_den.end(), 0.0);
- // Now normalize the densities...
std::transform(_M_den.begin(), _M_den.end(), _M_den.begin(),
std::bind2nd(std::divides<double>(), __sum));
- // ... and partial sums.
- std::transform(_M_cp.begin(), _M_cp.end(), _M_cp.begin(),
- std::bind2nd(std::divides<double>(), __sum));
- // Make sure the last cumulative probablility is one.
+
+ _M_cp.reserve(_M_den.size());
+ std::partial_sum(_M_den.begin(), _M_den.end(),
+ std::back_inserter(_M_cp));
+
+ // Make sure the last cumulative probability is one.
_M_cp[_M_cp.size() - 1] = 1.0;
+
+ for (size_t __k = 0; __k < _M_den.size(); ++__k)
+ _M_den[__k] /= _M_int[__k + 1] - _M_int[__k];
}
template<typename _RealType>
@@ -2179,17 +2128,19 @@ namespace std
_InputIteratorW __wbegin)
: _M_int(), _M_den(), _M_cp()
{
- do
+ if (__bbegin != __bend)
{
- _M_int.push_back(*__bbegin);
- ++__bbegin;
- if (__bbegin != __bend)
+ for (;;)
{
+ _M_int.push_back(*__bbegin);
+ ++__bbegin;
+ if (__bbegin == __bend)
+ break;
+
_M_den.push_back(*__wbegin);
++__wbegin;
}
}
- while (__bbegin != __bend);
_M_initialize();
}
@@ -2197,17 +2148,16 @@ namespace std
template<typename _RealType>
template<typename _Func>
piecewise_constant_distribution<_RealType>::param_type::
- param_type(initializer_list<_RealType> __bil, _Func __fw)
+ param_type(initializer_list<_RealType> __bl, _Func __fw)
: _M_int(), _M_den(), _M_cp()
{
- for (auto __biter = __bil.begin(); __biter != __bil.end(); ++__biter)
+ _M_int.reserve(__bl.size());
+ for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
_M_int.push_back(*__biter);
- for (size_t __i = 0; __i < _M_int.size() - 1; ++__i)
- {
- _RealType __x = 0.5 * (_M_int[__i] + _M_int[__i + 1]);
- _M_den.push_back(__fw(__x));
- }
+ _M_den.reserve(_M_int.size() - 1);
+ for (size_t __k = 0; __k < _M_int.size() - 1; ++__k)
+ _M_den.push_back(__fw(0.5 * (_M_int[__k + 1] + _M_int[__k])));
_M_initialize();
}
@@ -2218,18 +2168,16 @@ namespace std
param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
: _M_int(), _M_den(), _M_cp()
{
- for (size_t __i = 0; __i <= __nw; ++__i)
- {
- const _RealType __x = ((__nw - __i) * __xmin
- + __i * __xmax) / __nw;
- _M_int.push_back(__x);
- }
- for (size_t __i = 0; __i < __nw; ++__i)
- {
- const _RealType __x = ((__nw - __i - 0.5) * __xmin
- + (__i + 0.5) * __xmax) / __nw;
- _M_den.push_back(__fw(__x));
- }
+ const size_t __n = __nw == 0 ? 1 : __nw;
+ const _RealType __delta = (__xmax - __xmin) / __n;
+
+ _M_int.reserve(__n + 1);
+ for (size_t __k = 0; __k <= __nw; ++__k)
+ _M_int.push_back(__xmin + __k * __delta);
+
+ _M_den.reserve(__n);
+ for (size_t __k = 0; __k < __nw; ++__k)
+ _M_den.push_back(__fw(_M_int[__k] + 0.5 * __delta));
_M_initialize();
}
@@ -2241,7 +2189,7 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
@@ -2249,8 +2197,9 @@ namespace std
__param._M_cp.end(), __p);
const size_t __i = __pos - __param._M_cp.begin();
- return __param._M_int[__i]
- + (__p - __param._M_cp[__i]) / __param._M_den[__i];
+ const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
+
+ return __param._M_int[__i] + (__p - __pref) / __param._M_den[__i];
}
template<typename _RealType, typename _CharT, typename _Traits>
@@ -2300,6 +2249,7 @@ namespace std
__is >> __n;
std::vector<_RealType> __int_vec;
+ __int_vec.reserve(__n + 1);
for (size_t __i = 0; __i <= __n; ++__i)
{
_RealType __int;
@@ -2308,6 +2258,7 @@ namespace std
}
std::vector<double> __den_vec;
+ __den_vec.reserve(__n);
for (size_t __i = 0; __i < __n; ++__i)
{
double __den;
@@ -2331,10 +2282,12 @@ namespace std
if (_M_int.size() < 2)
{
_M_int.clear();
+ _M_int.reserve(2);
_M_int.push_back(_RealType(0));
_M_int.push_back(_RealType(1));
_M_den.clear();
+ _M_den.reserve(2);
_M_den.push_back(1.0);
_M_den.push_back(1.0);
@@ -2342,17 +2295,19 @@ namespace std
}
double __sum = 0.0;
- for (size_t __i = 0; __i < _M_int.size() - 1; ++__i)
+ _M_cp.reserve(_M_int.size() - 1);
+ _M_m.reserve(_M_int.size() - 1);
+ for (size_t __k = 0; __k < _M_int.size() - 1; ++__k)
{
- const _RealType __delta = _M_int[__i + 1] - _M_int[__i];
- __sum += 0.5 * (_M_den[__i + 1] + _M_den[__i]) * __delta;
+ const _RealType __delta = _M_int[__k + 1] - _M_int[__k];
+ __sum += 0.5 * (_M_den[__k + 1] + _M_den[__k]) * __delta;
_M_cp.push_back(__sum);
- _M_m.push_back((_M_den[__i + 1] - _M_den[__i]) / __delta);
+ _M_m.push_back((_M_den[__k + 1] - _M_den[__k]) / __delta);
}
// Now normalize the densities...
std::transform(_M_den.begin(), _M_den.end(), _M_den.begin(),
- std::bind2nd(std::divides<double>(),__sum));
+ std::bind2nd(std::divides<double>(), __sum));
// ... and partial sums...
std::transform(_M_cp.begin(), _M_cp.end(), _M_cp.begin(),
std::bind2nd(std::divides<double>(), __sum));
@@ -2361,13 +2316,7 @@ namespace std
std::bind2nd(std::divides<double>(), __sum));
// Make sure the last cumulative probablility is one.
_M_cp[_M_cp.size() - 1] = 1.0;
- }
-
- template<typename _RealType>
- piecewise_linear_distribution<_RealType>::param_type::
- param_type()
- : _M_int(), _M_den(), _M_cp(), _M_m()
- { _M_initialize(); }
+ }
template<typename _RealType>
template<typename _InputIteratorB, typename _InputIteratorW>
@@ -2389,10 +2338,12 @@ namespace std
template<typename _RealType>
template<typename _Func>
piecewise_linear_distribution<_RealType>::param_type::
- param_type(initializer_list<_RealType> __bil, _Func __fw)
+ param_type(initializer_list<_RealType> __bl, _Func __fw)
: _M_int(), _M_den(), _M_cp(), _M_m()
{
- for (auto __biter = __bil.begin(); __biter != __bil.end(); ++__biter)
+ _M_int.reserve(__bl.size());
+ _M_den.reserve(__bl.size());
+ for (auto __biter = __bl.begin(); __biter != __bl.end(); ++__biter)
{
_M_int.push_back(*__biter);
_M_den.push_back(__fw(*__biter));
@@ -2404,16 +2355,18 @@ namespace std
template<typename _RealType>
template<typename _Func>
piecewise_linear_distribution<_RealType>::param_type::
- param_type(size_t __nw, _RealType __xmin, _RealType __xmax,
- _Func __fw)
+ param_type(size_t __nw, _RealType __xmin, _RealType __xmax, _Func __fw)
: _M_int(), _M_den(), _M_cp(), _M_m()
{
- for (size_t __i = 0; __i <= __nw; ++__i)
+ const size_t __n = __nw == 0 ? 1 : __nw;
+ const _RealType __delta = (__xmax - __xmin) / __n;
+
+ _M_int.reserve(__n + 1);
+ _M_den.reserve(__n + 1);
+ for (size_t __k = 0; __k <= __nw; ++__k)
{
- const _RealType __x = ((__nw - __i) * __xmin
- + __i * __xmax) / __nw;
- _M_int.push_back(__x);
- _M_den.push_back(__fw(__x));
+ _M_int.push_back(__xmin + __k * __delta);
+ _M_den.push_back(__fw(_M_int[__k] + __delta));
}
_M_initialize();
@@ -2426,31 +2379,30 @@ namespace std
operator()(_UniformRandomNumberGenerator& __urng,
const param_type& __param)
{
- result_type __x;
- __detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
+ __detail::_Adaptor<_UniformRandomNumberGenerator, double>
__aurng(__urng);
const double __p = __aurng();
auto __pos = std::lower_bound(__param._M_cp.begin(),
__param._M_cp.end(), __p);
const size_t __i = __pos - __param._M_cp.begin();
+
+ const double __pref = __i > 0 ? __param._M_cp[__i - 1] : 0.0;
+
const double __a = 0.5 * __param._M_m[__i];
const double __b = __param._M_den[__i];
- const double __c = __param._M_cp[__i];
- const double __q = -0.5 * (__b
-#if _GLIBCXX_USE_C99_MATH_TR1
- + std::copysign(std::sqrt(__b * __b
- - 4.0 * __a * __c), __b));
-#else
- + (__b < 0.0 ? -1.0 : 1.0)
- * std::sqrt(__b * __b - 4.0 * __a * __c));
-#endif
- const double __x0 = __param._M_int[__i];
- const double __x1 = __q / __a;
- const double __x2 = __c / __q;
- __x = std::max(__x0 + __x1, __x0 + __x2);
+ const double __cm = __p - __pref;
+
+ _RealType __x = __param._M_int[__i];
+ if (__a == 0)
+ __x += __cm / __b;
+ else
+ {
+ const double __d = __b * __b + 4.0 * __a * __cm;
+ __x += 0.5 * (std::sqrt(__d) - __b) / __a;
+ }
- return __x;
+ return __x;
}
template<typename _RealType, typename _CharT, typename _Traits>
@@ -2500,6 +2452,7 @@ namespace std
__is >> __n;
std::vector<_RealType> __int_vec;
+ __int_vec.reserve(__n + 1);
for (size_t __i = 0; __i <= __n; ++__i)
{
_RealType __int;
@@ -2508,6 +2461,7 @@ namespace std
}
std::vector<double> __den_vec;
+ __den_vec.reserve(__n + 1);
for (size_t __i = 0; __i <= __n; ++__i)
{
double __den;
@@ -2527,7 +2481,7 @@ namespace std
seed_seq::seed_seq(std::initializer_list<_IntType> __il)
{
for (auto __iter = __il.begin(); __iter != __il.end(); ++__iter)
- _M_v.push_back(__detail::__mod<result_type, 1, 0,
+ _M_v.push_back(__detail::__mod<result_type,
__detail::_Shift<result_type, 32>::__value>(*__iter));
}
@@ -2535,7 +2489,7 @@ namespace std
seed_seq::seed_seq(_InputIterator __begin, _InputIterator __end)
{
for (_InputIterator __iter = __begin; __iter != __end; ++__iter)
- _M_v.push_back(__detail::__mod<result_type, 1, 0,
+ _M_v.push_back(__detail::__mod<result_type,
__detail::_Shift<result_type, 32>::__value>(*__iter));
}
@@ -2550,7 +2504,7 @@ namespace std
if (__begin == __end)
return;
- std::fill(__begin, __end, _Type(0x8b8b8b8bU));
+ std::fill(__begin, __end, _Type(0x8b8b8b8bu));
const size_t __n = __end - __begin;
const size_t __s = _M_v.size();
@@ -2569,8 +2523,8 @@ namespace std
^ __begin[(__k + __p) % __n]
^ __begin[(__k - 1) % __n]);
_Type __r1 = __arg ^ (__arg << 27);
- __r1 = __detail::__mod<_Type, 1664525U, 0U,
- __detail::_Shift<_Type, 32>::__value>(__r1);
+ __r1 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value,
+ 1664525u, 0u>(__r1);
_Type __r2 = __r1;
if (__k == 0)
__r2 += __s;
@@ -2578,8 +2532,8 @@ namespace std
__r2 += __k % __n + _M_v[__k - 1];
else
__r2 += __k % __n;
- __r2 = __detail::__mod<_Type, 1U, 0U,
- __detail::_Shift<_Type, 32>::__value>(__r2);
+ __r2 = __detail::__mod<_Type,
+ __detail::_Shift<_Type, 32>::__value>(__r2);
__begin[(__k + __p) % __n] += __r1;
__begin[(__k + __q) % __n] += __r2;
__begin[__k % __n] = __r2;
@@ -2591,11 +2545,11 @@ namespace std
+ __begin[(__k + __p) % __n]
+ __begin[(__k - 1) % __n]);
_Type __r3 = __arg ^ (__arg << 27);
- __r3 = __detail::__mod<_Type, 1566083941U, 0U,
- __detail::_Shift<_Type, 32>::__value>(__r3);
+ __r3 = __detail::__mod<_Type, __detail::_Shift<_Type, 32>::__value,
+ 1566083941u, 0u>(__r3);
_Type __r4 = __r3 - __k % __n;
- __r4 = __detail::__mod<_Type, 1U, 0U,
- __detail::_Shift<_Type, 32>::__value>(__r4);
+ __r4 = __detail::__mod<_Type,
+ __detail::_Shift<_Type, 32>::__value>(__r4);
__begin[(__k + __p) % __n] ^= __r4;
__begin[(__k + __q) % __n] ^= __r3;
__begin[__k % __n] = __r4;
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index c7a45f39bc1..81bef585940 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -828,7 +828,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ return _M_refcount._M_get_use_count(); }
void
- swap(__shared_ptr<_Tp, _Lp>&& __other) // never throws
+ swap(__shared_ptr<_Tp, _Lp>& __other) // never throws
{
std::swap(_M_ptr, __other._M_ptr);
_M_refcount._M_swap(__other._M_refcount);
@@ -938,16 +938,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>& __b)
{ __a.swap(__b); }
- template<typename _Tp, _Lock_policy _Lp>
- inline void
- swap(__shared_ptr<_Tp, _Lp>&& __a, __shared_ptr<_Tp, _Lp>& __b)
- { __a.swap(__b); }
-
- template<typename _Tp, _Lock_policy _Lp>
- inline void
- swap(__shared_ptr<_Tp, _Lp>& __a, __shared_ptr<_Tp, _Lp>&& __b)
- { __a.swap(__b); }
-
// 2.2.3.9 shared_ptr casts
/** @warning The seemingly equivalent
* <code>shared_ptr<_Tp, _Lp>(static_cast<_Tp*>(__r.get()))</code>
@@ -1367,16 +1357,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>& __b)
{ __a.swap(__b); }
- template<typename _Tp>
- inline void
- swap(shared_ptr<_Tp>&& __a, shared_ptr<_Tp>& __b)
- { __a.swap(__b); }
-
- template<typename _Tp>
- inline void
- swap(shared_ptr<_Tp>& __a, shared_ptr<_Tp>&& __b)
- { __a.swap(__b); }
-
// 20.8.13.2.10 shared_ptr casts.
template<typename _Tp, typename _Tp1>
inline shared_ptr<_Tp>
diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h
index 1a8ce69ca4b..803e7d996b3 100644
--- a/libstdc++-v3/include/debug/macros.h
+++ b/libstdc++-v3/include/debug/macros.h
@@ -80,7 +80,7 @@ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \
* range. Note that this macro is only valid when the container is a
* _Safe_sequence and the iterator is a _Safe_iterator.
*
- * @tbd We would like to be able to check for noninterference of
+ * @todo We would like to be able to check for noninterference of
* _Position and the range [_First, _Last), but that can't (in
* general) be done.
*/
diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
new file mode 100644
index 00000000000..c5ece926463
--- /dev/null
+++ b/libstdc++-v3/include/std/future
@@ -0,0 +1,925 @@
+// <future> -*- C++ -*-
+
+// 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file future
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_FUTURE
+#define _GLIBCXX_FUTURE 1
+
+#pragma GCC system_header
+
+#ifndef __GXX_EXPERIMENTAL_CXX0X__
+# include <c++0x_warning.h>
+#else
+
+#include <functional>
+#include <memory>
+#include <mutex>
+#include <condition_variable>
+#include <system_error>
+#include <exception>
+#include <cstdatomic>
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
+ && defined(_GLIBCXX_ATOMIC_BUILTINS_4)
+
+namespace std
+{
+ /**
+ * @defgroup futures Futures
+ * @ingroup concurrency
+ *
+ * Classes for futures support.
+ * @{
+ */
+
+ /// Error code for futures
+ enum class future_errc
+ { broken_promise, future_already_retrieved, promise_already_satisfied };
+
+ // TODO: requires concepts
+ // concept_map ErrorCodeEnum<future_errc> { }
+ template<>
+ struct is_error_code_enum<future_errc> : public true_type { };
+
+ /// Points to a statically-allocated object derived from error_category.
+ extern const error_category* const future_category;
+
+ // TODO: requires constexpr
+ inline error_code make_error_code(future_errc __errc)
+ { return error_code(static_cast<int>(__errc), *future_category); }
+
+ // TODO: requires constexpr
+ inline error_condition make_error_condition(future_errc __errc)
+ { return error_condition(static_cast<int>(__errc), *future_category); }
+
+ /// Exception type thrown by futures.
+ class future_error : public logic_error
+ {
+ public:
+ explicit future_error(future_errc __ec)
+ : logic_error("std::future_error"), _M_code(make_error_code(__ec))
+ { }
+
+ const error_code& code() const throw() { return _M_code; }
+
+ const char* what() const throw() { return _M_code.message().c_str(); }
+
+ private:
+ error_code _M_code;
+ };
+
+ // Forward declarations.
+ template<typename _Result>
+ class unique_future;
+
+ template<typename _Result>
+ class shared_future;
+
+ template<typename>
+ class packaged_task;
+
+ template<typename _Result>
+ class promise;
+
+ // Holds the result of a future
+ struct _Future_result_base
+ {
+ _Future_result_base() = default;
+ _Future_result_base(const _Future_result_base&) = delete;
+ _Future_result_base& operator=(const _Future_result_base&) = delete;
+
+ exception_ptr _M_error;
+
+ // _M_destroy() allows derived classes to control deallocation,
+ // which will be needed when allocator support is added to promise.
+ // See http://gcc.gnu.org/ml/libstdc++/2009-06/msg00032.html
+ virtual void _M_destroy() = 0;
+ struct _Deleter
+ {
+ void operator()(_Future_result_base* __fr) const { __fr->_M_destroy(); }
+ };
+
+ protected:
+ ~_Future_result_base() = default;
+ };
+
+ // TODO: use template alias when available
+ /*
+ template<typename _Res>
+ using _Future_ptr = unique_ptr<_Res, _Future_result_base::_Deleter>;
+ */
+ template<typename _Res>
+ struct _Future_ptr
+ {
+ typedef unique_ptr<_Res, _Future_result_base::_Deleter> type;
+ };
+
+ // State shared between a promise and one or more associated futures.
+ class _Future_state
+ {
+ typedef _Future_ptr<_Future_result_base>::type _Future_ptr_type;
+
+ public:
+ _Future_state() : _M_result(), _M_retrieved(false) { }
+
+ _Future_state(const _Future_state&) = delete;
+ _Future_state& operator=(const _Future_state&) = delete;
+
+ bool
+ is_ready()
+ { return _M_get() != 0; }
+
+ bool
+ has_exception()
+ {
+ _Future_result_base* const __res = _M_get();
+ return __res && !(__res->_M_error == 0);
+ }
+
+ bool
+ has_value()
+ {
+ _Future_result_base* const __res = _M_get();
+ return __res && (__res->_M_error == 0);
+ }
+
+ _Future_result_base&
+ wait()
+ {
+ unique_lock<mutex> __lock(_M_mutex);
+ if (!_M_ready())
+ _M_cond.wait(__lock, std::bind(&_Future_state::_M_ready, this));
+ return *_M_result;
+ }
+
+ template<typename _Rep, typename _Period>
+ bool
+ wait_for(const chrono::duration<_Rep, _Period>& __rel)
+ {
+ unique_lock<mutex> __lock(_M_mutex);
+ return _M_ready() || _M_cond.wait_for(__lock, __rel,
+ std::bind(&_Future_state::_M_ready, this));
+ }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs)
+ {
+ unique_lock<mutex> __lock(_M_mutex);
+ return _M_ready() || _M_cond.wait_until(__lock, __abs,
+ std::bind(&_Future_state::_M_ready, this));
+ }
+
+ void
+ _M_set_result(_Future_ptr_type __res)
+ {
+ {
+ lock_guard<mutex> __lock(_M_mutex);
+ if (_M_ready())
+ throw future_error(future_errc::promise_already_satisfied);
+ _M_result.swap(__res);
+ }
+ _M_cond.notify_all();
+ }
+
+ void
+ _M_break_promise(_Future_ptr_type __res)
+ {
+ if (static_cast<bool>(__res))
+ {
+ __res->_M_error
+ = std::copy_exception(future_error(future_errc::broken_promise));
+ {
+ lock_guard<mutex> __lock(_M_mutex);
+ _M_result.swap(__res);
+ }
+ _M_cond.notify_all();
+ }
+ }
+
+ // called when this object is passed to a unique_future
+ void
+ _M_set_retrieved_flag()
+ {
+ if (_M_retrieved.test_and_set())
+ throw future_error(future_errc::future_already_retrieved);
+ }
+
+ private:
+ _Future_result_base*
+ _M_get()
+ {
+ lock_guard<mutex> __lock(_M_mutex);
+ return _M_result.get();
+ }
+
+ bool _M_ready() const { return static_cast<bool>(_M_result); }
+
+ _Future_ptr_type _M_result;
+ mutex _M_mutex;
+ condition_variable _M_cond;
+ atomic_flag _M_retrieved;
+ };
+
+ // workaround for CWG issue 664 and c++/34022
+ template<typename _Result, bool = is_scalar<_Result>::value>
+ struct _Move_future_result
+ {
+ typedef _Result&& __rval_type;
+ static _Result&& _S_move(_Result& __res) { return std::move(__res); }
+ };
+
+ // specialization for scalar types returns rvalue not rvalue-reference
+ template<typename _Result>
+ struct _Move_future_result<_Result, true>
+ {
+ typedef _Result __rval_type;
+ static _Result _S_move(_Result __res) { return __res; }
+ };
+
+ template<typename _Result>
+ struct _Future_result : _Future_result_base
+ {
+ _Future_result() : _M_initialized() { }
+
+ ~_Future_result()
+ {
+ if (_M_initialized)
+ _M_value().~_Result();
+ }
+
+ // return lvalue, future will add const or rvalue-reference
+ _Result& _M_value()
+ { return *static_cast<_Result*>(_M_addr()); }
+
+ void
+ _M_set(const _Result& __res)
+ {
+ ::new (_M_addr()) _Result(__res);
+ _M_initialized = true;
+ }
+
+ void
+ _M_set(_Result&& __res)
+ {
+ typedef _Move_future_result<_Result> _Mover;
+ ::new (_M_addr()) _Result(_Mover::_S_move(__res));
+ _M_initialized = true;
+ }
+
+ private:
+ void _M_destroy() { delete this; }
+
+ void* _M_addr() { return static_cast<void*>(&_M_storage); }
+
+ typename aligned_storage<sizeof(_Result),
+ alignment_of<_Result>::value>::type _M_storage;
+ bool _M_initialized;
+ };
+
+ template<typename _Result>
+ struct _Future_result<_Result&> : _Future_result_base
+ {
+ _Future_result() : _M_value_ptr() { }
+
+ _Result* _M_value_ptr;
+
+ void _M_destroy() { delete this; }
+ };
+
+ template<>
+ struct _Future_result<void> : _Future_result_base
+ {
+ void _M_destroy() { delete this; }
+ };
+
+ // common implementation for unique_future and shared_future
+ template<typename _Result>
+ class _Future_impl
+ {
+ public:
+ // disable copying
+ _Future_impl(const _Future_impl&) = delete;
+ _Future_impl& operator=(const _Future_impl&) = delete;
+
+ // functions to check state and wait for ready
+ bool is_ready() const { return this->_M_state->is_ready(); }
+
+ bool has_exception() const { return this->_M_state->has_exception(); }
+
+ bool has_value() const { return this->_M_state->has_value(); }
+
+ void wait() const { this->_M_state->wait(); }
+
+ template<typename _Rep, typename _Period>
+ bool
+ wait_for(const chrono::duration<_Rep, _Period>& __rel) const
+ { return this->_M_state->wait_for(__rel); }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const
+ { return this->_M_state->wait_until(__abs); }
+
+ protected:
+ // wait for the state to be ready and rethrow any stored exception
+ _Future_result<_Result>&
+ _M_get_result()
+ {
+ _Future_result_base& __res = this->_M_state->wait();
+ if (!(__res._M_error == 0))
+ rethrow_exception(__res._M_error);
+ return static_cast<_Future_result<_Result>&>(__res);
+ }
+
+ typedef shared_ptr<_Future_state> _State_ptr;
+
+ // construction of a unique_future by promise::get_future()
+ explicit
+ _Future_impl(const _State_ptr& __state)
+ : _M_state(__state)
+ {
+ if (static_cast<bool>(this->_M_state))
+ this->_M_state->_M_set_retrieved_flag();
+ else
+ throw future_error(future_errc::future_already_retrieved);
+ }
+
+ // copy construction from a shared_future
+ explicit
+ _Future_impl(const shared_future<_Result>&);
+
+ // move construction from a unique_future
+ explicit
+ _Future_impl(unique_future<_Result>&&);
+
+ _State_ptr _M_state;
+ };
+
+ /// primary template for unique_future
+ template<typename _Result>
+ class unique_future : public _Future_impl<_Result>
+ {
+ typedef _Move_future_result<_Result> _Mover;
+
+ public:
+ /// Move constructor
+ unique_future(unique_future&& __uf) : _Base_type(std::move(__uf)) { }
+
+ // disable copying
+ unique_future(const unique_future&) = delete;
+ unique_future& operator=(const unique_future&) = delete;
+
+ // retrieving the value
+ typename _Mover::__rval_type
+ get()
+ { return _Mover::_S_move(this->_M_get_result()._M_value()); }
+
+ private:
+ typedef _Future_impl<_Result> _Base_type;
+ typedef typename _Base_type::_State_ptr _State_ptr;
+
+ friend class promise<_Result>;
+
+ explicit
+ unique_future(const _State_ptr& __state) : _Base_type(__state) { }
+ };
+
+ // partial specialization for unique_future<R&>
+ template<typename _Result>
+ class unique_future<_Result&> : public _Future_impl<_Result&>
+ {
+ public:
+ /// Move constructor
+ unique_future(unique_future&& __uf) : _Base_type(std::move(__uf)) { }
+
+ // disable copying
+ unique_future(const unique_future&) = delete;
+ unique_future& operator=(const unique_future&) = delete;
+
+ // retrieving the value
+ _Result& get() { return *this->_M_get_result()._M_value_ptr; }
+
+ private:
+ typedef _Future_impl<_Result&> _Base_type;
+ typedef typename _Base_type::_State_ptr _State_ptr;
+
+ friend class promise<_Result&>;
+
+ explicit
+ unique_future(const _State_ptr& __state) : _Base_type(__state) { }
+ };
+
+ // specialization for unique_future<void>
+ template<>
+ class unique_future<void> : public _Future_impl<void>
+ {
+ public:
+ /// Move constructor
+ unique_future(unique_future&& __uf) : _Base_type(std::move(__uf)) { }
+
+ // disable copying
+ unique_future(const unique_future&) = delete;
+ unique_future& operator=(const unique_future&) = delete;
+
+ // retrieving the value
+ void get() { this->_M_get_result(); }
+
+ private:
+ typedef _Future_impl<void> _Base_type;
+ typedef _Base_type::_State_ptr _State_ptr;
+
+ friend class promise<void>;
+
+ explicit
+ unique_future(const _State_ptr& __state) : _Base_type(__state) { }
+ };
+
+ /// primary template for shared_future
+ template<typename _Result>
+ class shared_future : public _Future_impl<_Result>
+ {
+ public:
+ /// Copy constructor
+ shared_future(const shared_future& __sf) : _Base_type(__sf) { }
+
+ /// Construct from a unique_future rvalue
+ shared_future(unique_future<_Result>&& __uf)
+ : _Base_type(std::move(__uf))
+ { }
+
+ shared_future& operator=(const shared_future&) = delete;
+
+ // retrieving the value
+ const _Result&
+ get()
+ { return this->_M_get_result()._M_value(); }
+
+ private:
+ typedef _Future_impl<_Result> _Base_type;
+ };
+
+ // partial specialization for shared_future<R&>
+ template<typename _Result>
+ class shared_future<_Result&> : public _Future_impl<_Result&>
+ {
+ public:
+ /// Copy constructor
+ shared_future(const shared_future& __sf) : _Base_type(__sf) { }
+
+ /// Construct from a unique_future rvalue
+ shared_future(unique_future<_Result&>&& __uf)
+ : _Base_type(std::move(__uf))
+ { }
+
+ shared_future& operator=(const shared_future&) = delete;
+
+ // retrieving the value
+ _Result& get() { return *this->_M_get_result()._M_value_ptr; }
+
+ private:
+ typedef _Future_impl<_Result&> _Base_type;
+ };
+
+ // specialization for shared_future<void>
+ template<>
+ class shared_future<void> : public _Future_impl<void>
+ {
+ public:
+ /// Copy constructor
+ shared_future(const shared_future& __sf) : _Base_type(__sf) { }
+
+ /// Construct from a unique_future rvalue
+ shared_future(unique_future<void>&& __uf)
+ : _Base_type(std::move(__uf))
+ { }
+
+ shared_future& operator=(const shared_future&) = delete;
+
+ // retrieving the value
+ void get() { this->_M_get_result(); }
+
+ private:
+ typedef _Future_impl<void> _Base_type;
+ };
+
+ // now we can define the protected _Future_impl constructors
+
+ template<typename _Result>
+ _Future_impl<_Result>::_Future_impl(const shared_future<_Result>& __sf)
+ : _M_state(__sf._M_state)
+ { }
+
+ template<typename _Result>
+ _Future_impl<_Result>::_Future_impl(unique_future<_Result>&& __uf)
+ : _M_state(std::move(__uf._M_state))
+ { }
+
+ /// primary template for promise
+ template<typename _Result>
+ class promise
+ {
+ public:
+ promise()
+ : _M_future(std::make_shared<_Future_state>()),
+ _M_storage(new _Future_result<_Result>())
+ { }
+
+ promise(promise&& __rhs)
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ // TODO: requires allocator concepts
+ /*
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a);
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator&, promise&& __rhs);
+ */
+
+ promise(const promise&) = delete;
+
+ ~promise()
+ {
+ if (static_cast<bool>(_M_future) && !_M_future.unique())
+ _M_future->_M_break_promise(std::move(_M_storage));
+ }
+
+ // assignment
+ promise&
+ operator=(promise&& __rhs)
+ {
+ promise(std::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ promise& operator=(const promise&) = delete;
+
+ void
+ swap(promise& __rhs)
+ {
+ _M_future.swap(__rhs._M_future);
+ _M_storage.swap(__rhs._M_storage);
+ }
+
+ // retrieving the result
+ unique_future<_Result>
+ get_future()
+ { return unique_future<_Result>(_M_future); }
+
+ // setting the result
+ void
+ set_value(const _Result& __r)
+ {
+ if (!_M_satisfied())
+ _M_storage->_M_set(__r);
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ void
+ set_value(_Result&& __r)
+ {
+ if (!_M_satisfied())
+ _M_storage->_M_set(_Mover::_S_move(__r));
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ void
+ set_exception(exception_ptr __p)
+ {
+ if (!_M_satisfied())
+ _M_storage->_M_error = __p;
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ private:
+ template<typename> friend class packaged_task;
+ typedef _Move_future_result<_Result> _Mover;
+ bool _M_satisfied() { return !static_cast<bool>(_M_storage); }
+ shared_ptr<_Future_state> _M_future;
+ typename _Future_ptr<_Future_result<_Result>>::type _M_storage;
+ };
+
+ // partial specialization for promise<R&>
+ template<typename _Result>
+ class promise<_Result&>
+ {
+ public:
+ promise()
+ : _M_future(std::make_shared<_Future_state>()),
+ _M_storage(new _Future_result<_Result&>())
+ { }
+
+ promise(promise&& __rhs)
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ // TODO: requires allocator concepts
+ /*
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a);
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator&, promise&& __rhs);
+ */
+
+ promise(const promise&) = delete;
+
+ ~promise()
+ {
+ if (static_cast<bool>(_M_future) && !_M_future.unique())
+ _M_future->_M_break_promise(std::move(_M_storage));
+ }
+
+ // assignment
+ promise&
+ operator=(promise&& __rhs)
+ {
+ promise(std::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ promise& operator=(const promise&) = delete;
+
+ void
+ swap(promise& __rhs)
+ {
+ _M_future.swap(__rhs._M_future);
+ _M_storage.swap(__rhs._M_storage);
+ }
+
+ // retrieving the result
+ unique_future<_Result&>
+ get_future()
+ { return unique_future<_Result&>(_M_future); }
+
+ // setting the result
+ void
+ set_value(_Result& __r)
+ {
+ if (!_M_satisfied())
+ _M_storage->_M_value_ptr = &__r;
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ void
+ set_exception(exception_ptr __p)
+ {
+ if (!_M_satisfied())
+ _M_storage->_M_error = __p;
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ private:
+ template<typename> friend class packaged_task;
+ bool _M_satisfied() { return !static_cast<bool>(_M_storage); }
+ shared_ptr<_Future_state> _M_future;
+ typename _Future_ptr<_Future_result<_Result&>>::type _M_storage;
+ };
+
+ // specialization for promise<void>
+ template<>
+ class promise<void>
+ {
+ public:
+ promise()
+ : _M_future(std::make_shared<_Future_state>()),
+ _M_storage(new _Future_result<void>())
+ { }
+
+ promise(promise&& __rhs)
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ // TODO: requires allocator concepts
+ /*
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a);
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator&, promise&& __rhs);
+ */
+
+ promise(const promise&) = delete;
+
+ ~promise()
+ {
+ if (static_cast<bool>(_M_future) && !_M_future.unique())
+ _M_future->_M_break_promise(std::move(_M_storage));
+ }
+
+ // assignment
+ promise&
+ operator=(promise&& __rhs)
+ {
+ promise(std::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ promise& operator=(const promise&) = delete;
+
+ void
+ swap(promise& __rhs)
+ {
+ _M_future.swap(__rhs._M_future);
+ _M_storage.swap(__rhs._M_storage);
+ }
+
+ // retrieving the result
+ unique_future<void>
+ get_future()
+ { return unique_future<void>(_M_future); }
+
+ // setting the result
+ void
+ set_value()
+ {
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ void
+ set_exception(exception_ptr __p)
+ {
+ if (!_M_satisfied())
+ _M_storage->_M_error = __p;
+ _M_future->_M_set_result(std::move(_M_storage));
+ }
+
+ private:
+ template<typename> friend class packaged_task;
+ bool _M_satisfied() { return !static_cast<bool>(_M_storage); }
+ shared_ptr<_Future_state> _M_future;
+ _Future_ptr<_Future_result<void>>::type _M_storage;
+ };
+
+ // TODO: requires allocator concepts
+ /*
+ template<typename _Result, class Alloc>
+ concept_map UsesAllocator<promise<_Result>, Alloc>
+ {
+ typedef Alloc allocator_type;
+ }
+ */
+
+ template<typename _Result, typename... _ArgTypes>
+ struct _Run_task
+ {
+ static void
+ _S_run(promise<_Result>& __p, function<_Result(_ArgTypes...)>& __f,
+ _ArgTypes... __args)
+ {
+ __p.set_value(__f(std::forward<_ArgTypes>(__args)...));
+ }
+ };
+
+ // specialization used by packaged_task<void(...)>
+ template<typename... _ArgTypes>
+ struct _Run_task<void, _ArgTypes...>
+ {
+ static void
+ _S_run(promise<void>& __p, function<void(_ArgTypes...)>& __f,
+ _ArgTypes... __args)
+ {
+ __f(std::forward<_ArgTypes>(__args)...);
+ __p.set_value();
+ }
+ };
+
+ /// packaged_task
+ template<typename _Result, typename... _ArgTypes>
+ class packaged_task<_Result(_ArgTypes...)>
+ {
+ public:
+ typedef _Result result_type;
+
+ // construction and destruction
+ packaged_task() { }
+
+ template<typename _Fn>
+ explicit
+ packaged_task(const _Fn& __fn) : _M_task(__fn) { }
+
+ template<typename _Fn>
+ explicit
+ packaged_task(_Fn&& __fn) : _M_task(std::move(__fn)) { }
+
+ explicit
+ packaged_task(_Result(*__fn)(_ArgTypes...)) : _M_task(__fn) { }
+
+ // TODO: requires allocator concepts
+ /*
+ template<typename _Fn, typename _Allocator>
+ explicit
+ packaged_task(allocator_arg_t __tag, const _Allocator& __a, _Fn __fn)
+ : _M_task(__tag, __a, __fn), _M_promise(__tag, __a)
+ { }
+
+ template<typename _Fn, typename _Allocator>
+ explicit
+ packaged_task(allocator_arg_t __tag, const _Allocator& __a, _Fn&& __fn)
+ : _M_task(__tag, __a, std::move(__fn)), _M_promise(__tag, __a)
+ { }
+ */
+
+ ~packaged_task() = default;
+
+ // no copy
+ packaged_task(packaged_task&) = delete;
+ packaged_task& operator=(packaged_task&) = delete;
+
+ // move support
+ packaged_task(packaged_task&& __other)
+ { this->swap(__other); }
+
+ packaged_task& operator=(packaged_task&& __other)
+ {
+ packaged_task(std::move(__other)).swap(*this);
+ return *this;
+ }
+
+ void
+ swap(packaged_task& __other)
+ {
+ _M_task.swap(__other._M_task);
+ _M_promise.swap(__other._M_promise);
+ }
+
+ explicit operator bool() const { return static_cast<bool>(_M_task); }
+
+ // result retrieval
+ unique_future<_Result>
+ get_future()
+ {
+ try
+ {
+ return _M_promise.get_future();
+ }
+ catch (const future_error& __e)
+ {
+ if (__e.code() == future_errc::future_already_retrieved)
+ throw std::bad_function_call();
+ throw;
+ }
+ }
+
+ // execution
+ void
+ operator()(_ArgTypes... __args)
+ {
+ if (!static_cast<bool>(_M_task) || _M_promise._M_satisfied())
+ throw std::bad_function_call();
+ try
+ {
+ _Run_task<_Result, _ArgTypes...>::_S_run(_M_promise, _M_task,
+ std::forward<_ArgTypes>(__args)...);
+ }
+ catch (...)
+ {
+ _M_promise.set_exception(current_exception());
+ }
+ }
+
+ void reset() { promise<_Result>().swap(_M_promise); }
+
+ private:
+ function<_Result(_ArgTypes...)> _M_task;
+ promise<_Result> _M_promise;
+ };
+
+ // @} group futures
+}
+
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+ // && _GLIBCXX_ATOMIC_BUILTINS_4
+
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
+#endif // _GLIBCXX_FUTURE
diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio
index f0e8831c597..4524f092328 100644
--- a/libstdc++-v3/include/std/ratio
+++ b/libstdc++-v3/include/std/ratio
@@ -46,7 +46,7 @@ namespace std
* @defgroup ratio Rational Arithmetic
* @ingroup utilities
*
- * Compile time representation of fininte rational numbers.
+ * Compile time representation of finite rational numbers.
* @{
*/
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index fbdfe2ee53f..bf282cc0365 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -135,7 +135,7 @@ namespace std
~thread()
{
if (joinable())
- detach();
+ std::terminate();
}
thread& operator=(const thread&) = delete;
@@ -143,7 +143,7 @@ namespace std
thread& operator=(thread&& __t)
{
if (joinable())
- detach();
+ std::terminate();
swap(__t);
return *this;
}
diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h
index 37f3132d7ae..23477c9c3a6 100644
--- a/libstdc++-v3/libsupc++/exception_ptr.h
+++ b/libstdc++-v3/libsupc++/exception_ptr.h
@@ -123,7 +123,7 @@ namespace std
exception_ptr&
operator=(exception_ptr&& __o) throw()
{
- exception_ptr(__o).swap(*this);
+ exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
return *this;
}
#endif
@@ -133,16 +133,6 @@ namespace std
void
swap(exception_ptr&) throw();
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
- void
- swap(exception_ptr &&__o) throw()
- {
- void *__tmp = _M_exception_object;
- _M_exception_object = __o._M_exception_object;
- __o._M_exception_object = __tmp;
- }
-#endif
-
#ifdef _GLIBCXX_EH_PTR_COMPAT
// Retained for compatibility with CXXABI_1.3.
bool operator!() const throw() __attribute__ ((__pure__));
diff --git a/libstdc++-v3/python/Makefile.am b/libstdc++-v3/python/Makefile.am
index bcc8afea1eb..50cc6d94541 100644
--- a/libstdc++-v3/python/Makefile.am
+++ b/libstdc++-v3/python/Makefile.am
@@ -24,7 +24,7 @@
include $(top_srcdir)/fragment.am
## Where to install the module code.
-pythondir = $(pkgdatadir)/python
+pythondir = $(datadir)/gcc-$(gcc_version)/python
all-local: gdb.py
@@ -34,10 +34,27 @@ nobase_python_DATA = \
libstdcxx/__init__.py
gdb.py: hook.in Makefile
- sed -e 's,@dir@,$(pythondir),' < $(srcdir)/hook.in > $@
+ sed -e 's,@pythondir@,$(pythondir),' \
+ -e 's,@toolexeclibdir@,$(toolexeclibdir),' < $(srcdir)/hook.in > $@
install-data-local: gdb.py
@$(mkdir_p) $(DESTDIR)$(toolexeclibdir)
- @libname=`cd $(toolexeclibdir) && ls -r libstdc++* | fgrep -v gdb.py | sed 1q`; \
+## We want to install gdb.py as SOMETHING-gdb.py. SOMETHING is the
+## full name of the final library. We want to ignore symlinks, the
+## .la file, and any previous -gdb.py file. This is inherently
+## fragile, but there does not seem to be a better option, because
+## libtool hides the real names from us.
+ @here=`pwd`; cd $(toolexeclibdir); \
+ for file in libstdc++*; do \
+ case $$file in \
+ *-gdb.py) ;; \
+ *.la) ;; \
+ *) if test -h $$file; then \
+ continue; \
+ fi; \
+ libname=$$file;; \
+ esac; \
+ done; \
+ cd $$here; \
echo " $(INSTALL_DATA) gdb.py $(DESTDIR)$(toolexeclibdir)/$$libname-gdb.py"; \
$(INSTALL_DATA) gdb.py $(DESTDIR)$(toolexeclibdir)/$$libname-gdb.py
diff --git a/libstdc++-v3/python/Makefile.in b/libstdc++-v3/python/Makefile.in
index 879f040d606..88cc7ea34c3 100644
--- a/libstdc++-v3/python/Makefile.in
+++ b/libstdc++-v3/python/Makefile.in
@@ -298,7 +298,7 @@ WARN_CXXFLAGS = \
# -I/-D flags to pass when compiling.
AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
-pythondir = $(pkgdatadir)/python
+pythondir = $(datadir)/gcc-$(gcc_version)/python
nobase_python_DATA = \
libstdcxx/v6/printers.py \
libstdcxx/v6/__init__.py \
@@ -492,11 +492,23 @@ uninstall-am: uninstall-info-am uninstall-nobase_pythonDATA
all-local: gdb.py
gdb.py: hook.in Makefile
- sed -e 's,@dir@,$(pythondir),' < $(srcdir)/hook.in > $@
+ sed -e 's,@pythondir@,$(pythondir),' \
+ -e 's,@toolexeclibdir@,$(toolexeclibdir),' < $(srcdir)/hook.in > $@
install-data-local: gdb.py
@$(mkdir_p) $(DESTDIR)$(toolexeclibdir)
- @libname=`cd $(toolexeclibdir) && ls -r libstdc++* | fgrep -v gdb.py | sed 1q`; \
+ @here=`pwd`; cd $(toolexeclibdir); \
+ for file in libstdc++*; do \
+ case $$file in \
+ *-gdb.py) ;; \
+ *.la) ;; \
+ *) if test -h $$file; then \
+ continue; \
+ fi; \
+ libname=$$file;; \
+ esac; \
+ done; \
+ cd $$here; \
echo " $(INSTALL_DATA) gdb.py $(DESTDIR)$(toolexeclibdir)/$$libname-gdb.py"; \
$(INSTALL_DATA) gdb.py $(DESTDIR)$(toolexeclibdir)/$$libname-gdb.py
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/libstdc++-v3/python/hook.in b/libstdc++-v3/python/hook.in
index fe7c0722484..120e187ed19 100644
--- a/libstdc++-v3/python/hook.in
+++ b/libstdc++-v3/python/hook.in
@@ -16,11 +16,44 @@
import sys
import gdb
+import os
+import os.path
-# Update module path.
-dir = '@dir@'
-if not dir in sys.path:
- sys.path.insert(0, dir)
+pythondir = '@pythondir@'
+libdir = '@toolexeclibdir@'
+
+# This file might be loaded when there is no current objfile. This
+# can happen if the user loads it manually. In this case we don't
+# update sys.path; instead we just hope the user managed to do that
+# beforehand.
+if gdb.current_objfile () is not None:
+ # Update module path. We want to find the relative path from libdir
+ # to pythondir, and then we want to apply that relative path to the
+ # directory holding the objfile with which this file is associated.
+ # This preserves relocatability of the gcc tree.
+
+ # Do a simple normalization that removes duplicate separators.
+ pythondir = os.path.normpath (pythondir)
+ libdir = os.path.normpath (libdir)
+
+ prefix = os.path.commonprefix ([libdir, pythondir])
+ # In some bizarre configuration we might have found a match in the
+ # middle of a directory name.
+ if prefix[-1] != '/':
+ prefix = os.path.dirname (prefix)
+
+ # Strip off the prefix.
+ pythondir = pythondir[len (prefix):]
+ libdir = libdir[len (prefix):]
+
+ # Compute the ".."s needed to get from libdir to the prefix.
+ dotdots = ('..' + os.sep) * len (libdir.split (os.sep))
+
+ objfile = gdb.current_objfile ().filename
+ dir = os.path.join (os.path.dirname (objfile), dotdots, pythondir)
+
+ if not dir in sys.path:
+ sys.path.insert(0, dir)
# Load the pretty-printers.
from libstdcxx.v6.printers import register_libstdcxx_printers
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 7b22e8a0bdc..e2bb231e15a 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -277,17 +277,17 @@ class StdMapPrinter:
def __init__ (self, typename, val):
self.typename = typename
self.val = val
- self.iter = RbtreeIterator (val)
def to_string (self):
- return '%s with %d elements' % (self.typename, len (self.iter))
+ return '%s with %d elements' % (self.typename,
+ len (RbtreeIterator (self.val)))
def children (self):
keytype = self.val.type.template_argument(0).const()
valuetype = self.val.type.template_argument(1)
nodetype = gdb.lookup_type('std::_Rb_tree_node< std::pair< %s, %s > >' % (keytype, valuetype))
nodetype = nodetype.pointer()
- return self._iter (self.iter, nodetype)
+ return self._iter (RbtreeIterator (self.val), nodetype)
def display_hint (self):
return 'map'
@@ -317,15 +317,15 @@ class StdSetPrinter:
def __init__ (self, typename, val):
self.typename = typename
self.val = val
- self.iter = RbtreeIterator (val)
def to_string (self):
- return '%s with %d elements' % (self.typename, len (self.iter))
+ return '%s with %d elements' % (self.typename,
+ len (RbtreeIterator (self.val)))
def children (self):
keytype = self.val.type.template_argument(0)
nodetype = gdb.lookup_type('std::_Rb_tree_node< %s >' % keytype).pointer()
- return self._iter (self.iter, nodetype)
+ return self._iter (RbtreeIterator (self.val), nodetype)
class StdBitsetPrinter:
"Print a std::bitset"
@@ -452,8 +452,6 @@ class StdStringPrinter:
encoding = gdb.parameter('target-charset')
elif encoding == 1:
encoding = gdb.parameter('target-wide-charset')
- elif isinstance(encoding, WideEncoding):
- encoding = encoding.value
return self.val['_M_dataplus']['_M_p'].string(encoding)
def display_hint (self):
@@ -559,7 +557,7 @@ def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
# Get the type.
- type = val.type;
+ type = val.type
# If it points to a reference, get the reference.
if type.code == gdb.TYPE_CODE_REF:
@@ -587,10 +585,10 @@ def build_libstdcxx_dictionary ():
# libstdc++ objects requiring pretty-printing.
# In order from:
# http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html
- pretty_printers_dict[re.compile('^std::basic_string<char,.*>$')] = lambda val: StdStringPrinter(0, val)
- pretty_printers_dict[re.compile('^std::basic_string<wchar_t,.*>$')] = lambda val: StdStringPrinter(1, val)
- pretty_printers_dict[re.compile('^std::basic_string<char16_t,.*>$')] = lambda val: StdStringPrinter('UTF-16', val)
- pretty_printers_dict[re.compile('^std::basic_string<char32_t,.*>$')] = lambda val: StdStringPrinter('UTF-32', val)
+ pretty_printers_dict[re.compile('^std::basic_string<char(,.*)?>$')] = lambda val: StdStringPrinter(0, val)
+ pretty_printers_dict[re.compile('^std::basic_string<wchar_t(,.*)?>$')] = lambda val: StdStringPrinter(1, val)
+ pretty_printers_dict[re.compile('^std::basic_string<char16_t(,.*)?>$')] = lambda val: StdStringPrinter('UTF-16', val)
+ pretty_printers_dict[re.compile('^std::basic_string<char32_t(,.*)?>$')] = lambda val: StdStringPrinter('UTF-32', val)
pretty_printers_dict[re.compile('^std::bitset<.*>$')] = StdBitsetPrinter
pretty_printers_dict[re.compile('^std::deque<.*>$')] = StdDequePrinter
pretty_printers_dict[re.compile('^std::list<.*>$')] = StdListPrinter
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index d218ceaa9ca..4295d4dda66 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -189,6 +189,7 @@ sources = \
condition_variable.cc \
chrono.cc \
thread.cc \
+ future.cc \
${host_sources} \
${host_sources_extra}
@@ -297,6 +298,11 @@ thread.lo: thread.cc
thread.o: thread.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
+future.lo: future.cc
+ $(LTCXXCOMPILE) -std=gnu++0x -c $<
+future.o: future.cc
+ $(CXXCOMPILE) -std=gnu++0x -c $<
+
if GLIBCXX_LDBL_COMPAT
# Use special rules for compatibility-ldbl.cc compilation, as we need to
# pass -mlong-double-64.
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 9ee5275198b..9134f0472d2 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -87,10 +87,11 @@ am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \
ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
string-inst.cc valarray-inst.cc wlocale-inst.cc \
wstring-inst.cc mutex.cc condition_variable.cc chrono.cc \
- thread.cc atomicity.cc codecvt_members.cc collate_members.cc \
- ctype_members.cc messages_members.cc monetary_members.cc \
- numeric_members.cc time_members.cc basic_file.cc c++locale.cc \
- compatibility-ldbl.cc parallel_list.cc parallel_settings.cc
+ thread.cc future.cc atomicity.cc codecvt_members.cc \
+ collate_members.cc ctype_members.cc messages_members.cc \
+ monetary_members.cc numeric_members.cc time_members.cc \
+ basic_file.cc c++locale.cc compatibility-ldbl.cc \
+ parallel_list.cc parallel_settings.cc
am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
ctype_members.lo messages_members.lo monetary_members.lo \
numeric_members.lo time_members.lo
@@ -113,7 +114,7 @@ am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \
ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \
string-inst.lo valarray-inst.lo wlocale-inst.lo \
wstring-inst.lo mutex.lo condition_variable.lo chrono.lo \
- thread.lo $(am__objects_1) $(am__objects_4)
+ thread.lo future.lo $(am__objects_1) $(am__objects_4)
am_libstdc___la_OBJECTS = $(am__objects_5)
libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -441,6 +442,7 @@ sources = \
condition_variable.cc \
chrono.cc \
thread.cc \
+ future.cc \
${host_sources} \
${host_sources_extra}
@@ -908,6 +910,11 @@ thread.lo: thread.cc
thread.o: thread.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
+future.lo: future.cc
+ $(LTCXXCOMPILE) -std=gnu++0x -c $<
+future.o: future.cc
+ $(CXXCOMPILE) -std=gnu++0x -c $<
+
# Use special rules for compatibility-ldbl.cc compilation, as we need to
# pass -mlong-double-64.
@GLIBCXX_LDBL_COMPAT_TRUE@compatibility-ldbl.lo: compatibility-ldbl.cc
diff --git a/libstdc++-v3/src/future.cc b/libstdc++-v3/src/future.cc
new file mode 100644
index 00000000000..ab9d5dbcc69
--- /dev/null
+++ b/libstdc++-v3/src/future.cc
@@ -0,0 +1,73 @@
+// future -*- C++ -*-
+
+// 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+#include <future>
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
+ && defined(_GLIBCXX_ATOMIC_BUILTINS_4)
+namespace
+{
+ struct future_error_category : public std::error_category
+ {
+ virtual const char*
+ name() const
+ { return "future"; }
+
+ virtual std::string message(int __ec) const
+ {
+ std::string __msg;
+ switch (std::future_errc(__ec))
+ {
+ case std::future_errc::broken_promise:
+ __msg = "Broken promise";
+ break;
+ case std::future_errc::future_already_retrieved:
+ __msg = "Future already retrieved";
+ break;
+ case std::future_errc::promise_already_satisfied:
+ __msg = "Promise already satisfied";
+ break;
+ default:
+ __msg = "Unknown error";
+ break;
+ }
+ return __msg;
+ }
+ };
+
+ const future_error_category&
+ __future_category_instance()
+ {
+ static const future_error_category __fec;
+ return __fec;
+ }
+}
+
+namespace std
+{
+ const error_category* const future_category = &__future_category_instance();
+}
+
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+ // && _GLIBCXX_ATOMIC_BUILTINS_4
diff --git a/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc b/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc
new file mode 100644
index 00000000000..ce97bc28c25
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/exception_ptr/move.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+#include <exception>
+#include <utility>
+#include <testsuite_hooks.h>
+
+// Verify move construction and assignment are efficient and do not copy.
+// This behaviour is a GNU extension provided for efficiency.
+void test01()
+{
+ bool test = true;
+
+ std::exception_ptr p1 = std::copy_exception(test);
+ std::exception_ptr p2 = std::move(p1);
+ VERIFY( p1 == 0 );
+ VERIFY( !(p2 == 0) );
+
+ p1 = std::move(p2);
+ VERIFY( !(p1 == 0) );
+ VERIFY( p2 == 0 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc b/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc
index 440ac76a7a1..e1524cc1851 100644
--- a/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc
+++ b/libstdc++-v3/testsuite/20_util/owner_less/cmp.cc
@@ -32,16 +32,18 @@ struct B { A a[2]; };
int
test01()
{
- // test empty shared_ptrs compare equivalent
- std::owner_less<std::shared_ptr<A>> less;
- std::owner_less<std::weak_ptr<A>> wless;
- std::shared_ptr<A> p1;
- std::shared_ptr<A> p2;
- VERIFY( !less(p1, p2) && !less(p2, p1) );
- std::weak_ptr<A> p3;
- VERIFY( !less(p1, p3) && !less(p3, p1) );
- VERIFY( !wless(p1, p3) && !wless(p3, p1) );
- return 0;
+ bool test __attribute__((unused)) = true;
+
+ // test empty shared_ptrs compare equivalent
+ std::owner_less<std::shared_ptr<A>> less;
+ std::owner_less<std::weak_ptr<A>> wless;
+ std::shared_ptr<A> p1;
+ std::shared_ptr<A> p2;
+ VERIFY( !less(p1, p2) && !less(p2, p1) );
+ std::weak_ptr<A> p3;
+ VERIFY( !less(p1, p3) && !less(p3, p1) );
+ VERIFY( !wless(p1, p3) && !wless(p3, p1) );
+ return 0;
}
@@ -49,6 +51,8 @@ test01()
int
test02()
{
+ bool test __attribute__((unused)) = true;
+
std::owner_less<std::shared_ptr<A>> less;
std::owner_less<std::weak_ptr<A>> wless;
@@ -80,6 +84,8 @@ test02()
int
test03()
{
+ bool test __attribute__((unused)) = true;
+
std::owner_less<std::shared_ptr<A>> less;
std::owner_less<std::weak_ptr<A>> wless;
@@ -102,6 +108,8 @@ test03()
int
test04()
{
+ bool test __attribute__((unused)) = true;
+
std::owner_less<std::shared_ptr<A>> less;
std::shared_ptr<A> a[3];
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc
index 3e9db75802c..9991fa761bc 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/cmp.cc
@@ -36,13 +36,15 @@ struct B : A
int
test01()
{
- // test empty shared_ptrs compare equivalent
- std::shared_ptr<A> p1;
- std::shared_ptr<B> p2;
- VERIFY( p1 == p2 );
- VERIFY( !(p1 != p2) );
- VERIFY( !(p1 < p2) && !(p2 < p1) );
- return 0;
+ bool test __attribute__((unused)) = true;
+
+ // test empty shared_ptrs compare equivalent
+ std::shared_ptr<A> p1;
+ std::shared_ptr<B> p2;
+ VERIFY( p1 == p2 );
+ VERIFY( !(p1 != p2) );
+ VERIFY( !(p1 < p2) && !(p2 < p1) );
+ return 0;
}
@@ -50,6 +52,8 @@ test01()
int
test02()
{
+ bool test __attribute__((unused)) = true;
+
std::shared_ptr<A> A_default;
std::shared_ptr<A> A_from_A(new A);
@@ -78,6 +82,8 @@ test02()
int
test03()
{
+ bool test __attribute__((unused)) = true;
+
std::shared_ptr<A> p1;
// check other operators are defined
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc
index 7f35dbe80d5..b51b222a028 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/comparison/less.cc
@@ -41,6 +41,8 @@ namespace std
int
test01()
{
+ bool test __attribute__((unused)) = true;
+
std::less<std::shared_ptr<A>> less;
// test empty shared_ptrs compare equivalent
std::shared_ptr<A> p1;
@@ -55,6 +57,8 @@ test01()
int
test02()
{
+ bool test __attribute__((unused)) = true;
+
std::less<std::shared_ptr<A>> less;
std::shared_ptr<A> empty;
@@ -77,6 +81,8 @@ test02()
int
test03()
{
+ bool test __attribute__((unused)) = true;
+
std::less<std::shared_ptr<A>> less;
A a;
diff --git a/libstdc++-v3/testsuite/20_util/tuple/swap.cc b/libstdc++-v3/testsuite/20_util/tuple/swap.cc
index 1e65f0521cb..6dab446bfe9 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/swap.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/swap.cc
@@ -56,6 +56,8 @@ make_move_only (int i)
void test01()
{
+ bool test __attribute__((unused)) = true;
+
std::tuple<> t1, t2;
std::swap(t1, t2);
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc
index 786e7eb169e..1081f93d338 100644
--- a/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc
+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/observers/owner_before.cc
@@ -30,6 +30,8 @@ struct B { };
int
test01()
{
+ bool test __attribute__((unused)) = true;
+
// test empty weak_ptrs compare equivalent
std::weak_ptr<A> p1;
std::weak_ptr<B> p2;
@@ -45,6 +47,8 @@ test01()
int
test02()
{
+ bool test __attribute__((unused)) = true;
+
std::shared_ptr<A> a0;
std::weak_ptr<A> w0(a0);
diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc
index d820776e3a8..cb6c29ac8d1 100644
--- a/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc
@@ -15,51 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.2 list capacity [lib.list.capacity]
-
+#include "1.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// This test verifies the following.
-//
-// 23.2.2 bool empty() const
-// 23.2.2 size_type size() const
-// 23.2.2 iterator begin()
-// 23.2.2 iterator end()
-// 23.2.2.3 void push_back(const T&)
-// 23.2.2 size_type max_size() const
-// 23.2.2.2 void resize(size_type s, T c = T())
-//
-template<typename _Tp>
-void
-capacity01()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator_type;
-
- list_type list0101;
- VERIFY(list0101.empty());
- VERIFY(list0101.size() == 0);
-
- list0101.push_back(1);
- VERIFY(!list0101.empty());
- VERIFY(list0101.size() == 1);
-
- list0101.resize(3, 2);
- VERIFY(!list0101.empty());
- VERIFY(list0101.size() == 3);
-
- iterator_type i = list0101.begin();
- VERIFY(*i == 1); ++i;
- VERIFY(*i == 2); ++i;
- VERIFY(*i == 2); ++i;
- VERIFY(i == list0101.end());
-
- list0101.resize(0);
- VERIFY(list0101.empty());
- VERIFY(list0101.size() == 0);
-}
int
main()
diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/1.h b/libstdc++-v3/testsuite/23_containers/list/capacity/1.h
new file mode 100644
index 00000000000..4a2f2bc06a2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/capacity/1.h
@@ -0,0 +1,61 @@
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.2 list capacity [lib.list.capacity]
+
+#include <testsuite_hooks.h>
+
+// This test verifies the following.
+//
+// 23.2.2 bool empty() const
+// 23.2.2 size_type size() const
+// 23.2.2 iterator begin()
+// 23.2.2 iterator end()
+// 23.2.2.3 void push_back(const T&)
+// 23.2.2 size_type max_size() const
+// 23.2.2.2 void resize(size_type s, T c = T())
+//
+template<typename _Tp>
+void
+capacity01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator_type;
+
+ list_type list0101;
+ VERIFY(list0101.empty());
+ VERIFY(list0101.size() == 0);
+
+ list0101.push_back(1);
+ VERIFY(!list0101.empty());
+ VERIFY(list0101.size() == 1);
+
+ list0101.resize(3, 2);
+ VERIFY(!list0101.empty());
+ VERIFY(list0101.size() == 3);
+
+ iterator_type i = list0101.begin();
+ VERIFY(*i == 1); ++i;
+ VERIFY(*i == 2); ++i;
+ VERIFY(*i == 2); ++i;
+ VERIFY(i == list0101.end());
+
+ list0101.resize(0);
+ VERIFY(list0101.empty());
+ VERIFY(list0101.size() == 0);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc
index a223bc85007..31dacb59253 100644
--- a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc
@@ -18,70 +18,12 @@
// <http://www.gnu.org/licenses/>.
//
+#include "check_construct_destroy.h"
#include <list>
-#include <iterator>
-#include <testsuite_allocator.h>
-
-
-template<typename _Tp>
-bool
-construct_destroy()
-{
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator_type;
-
- using namespace __gnu_test;
- const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
- bool ok = true;
-
- tracker_allocator_counter::reset();
- {
- list_type c;
- ok = check_construct_destroy("empty container", 0, 0) && ok;
- }
- ok = check_construct_destroy("empty container", 0, 0) && ok;
-
-
- tracker_allocator_counter::reset();
- {
- list_type c(arr10, arr10 + 10);
- ok = check_construct_destroy("Construct from range", 10, 0) && ok;
- }
- ok = check_construct_destroy("Construct from range", 10, 10) && ok;
-
- {
- list_type c(arr10, arr10 + 10);
- tracker_allocator_counter::reset();
- c.insert(c.begin(), arr10[0]);
- ok = check_construct_destroy("Insert element", 1, 0) && ok;
- }
- ok = check_construct_destroy("Insert element", 1, 11) && ok;
-
- {
- list_type c(arr10, arr10 + 10);
- tracker_allocator_counter::reset();
- iterator_type i5 = c.begin();
- std::advance(i5, 5);
- c.insert(i5, arr10, arr10+3);
- ok = check_construct_destroy("Insert short range", 3, 0) && ok;
- }
- ok = check_construct_destroy("Insert short range", 3, 13) && ok;
-
- {
- list_type c(arr10, arr10 + 10);
- tracker_allocator_counter::reset();
- iterator_type i7 = c.begin();
- std::advance(i7, 5);
- c.insert(i7, arr10, arr10+10);
- ok = check_construct_destroy("Insert long range", 10, 0) && ok;
- }
- ok = check_construct_destroy("Insert long range", 10, 20) && ok;
-
- return ok ? 0 : 1;
-}
int main()
{
- construct_destroy<std::list<int, __gnu_test::tracker_allocator<int> > >();
+ typedef __gnu_test::tracker_allocator<int> allocator_type;
+ construct_destroy<std::list<int, allocator_type> >();
return 0;
}
diff --git a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h
new file mode 100644
index 00000000000..14da42dc875
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h
@@ -0,0 +1,79 @@
+// 2004-07-26 Matt Austern <austern@apple.com>
+//
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <iterator>
+#include <testsuite_allocator.h>
+
+template<typename _Tp>
+bool
+construct_destroy()
+{
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator_type;
+
+ using namespace __gnu_test;
+ const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
+ bool ok = true;
+
+ tracker_allocator_counter::reset();
+ {
+ list_type c;
+ ok = check_construct_destroy("empty container", 0, 0) && ok;
+ }
+ ok = check_construct_destroy("empty container", 0, 0) && ok;
+
+
+ tracker_allocator_counter::reset();
+ {
+ list_type c(arr10, arr10 + 10);
+ ok = check_construct_destroy("Construct from range", 10, 0) && ok;
+ }
+ ok = check_construct_destroy("Construct from range", 10, 10) && ok;
+
+ {
+ list_type c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ c.insert(c.begin(), arr10[0]);
+ ok = check_construct_destroy("Insert element", 1, 0) && ok;
+ }
+ ok = check_construct_destroy("Insert element", 1, 11) && ok;
+
+ {
+ list_type c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ iterator_type i5 = c.begin();
+ std::advance(i5, 5);
+ c.insert(i5, arr10, arr10+3);
+ ok = check_construct_destroy("Insert short range", 3, 0) && ok;
+ }
+ ok = check_construct_destroy("Insert short range", 3, 13) && ok;
+
+ {
+ list_type c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ iterator_type i7 = c.begin();
+ std::advance(i7, 5);
+ c.insert(i7, arr10, arr10+10);
+ ok = check_construct_destroy("Insert long range", 10, 0) && ok;
+ }
+ ok = check_construct_destroy("Insert long range", 10, 20) && ok;
+
+ return ok ? 0 : 1;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/1.cc b/libstdc++-v3/testsuite/23_containers/list/cons/1.cc
index 2228a506fe9..da469ebb194 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/1.cc
@@ -15,55 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "1.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// A nontrivial type.
-template<typename T>
- struct A { };
-
-// Another nontrivial type
-struct B { };
-
-// Default constructor, basic properties
-//
-// This test verifies the following.
-// 23.2.2.1 explicit list(const a& = Allocator())
-// 23.1 (7) iterator behaviour of empty containers
-// 23.2.2 iterator begin()
-// 23.2.2 iterator end()
-// 23.2.2 size_type size() const
-// 23.2.2 existence of required typedefs
-//
-template<typename _Tp>
-void
-cons01()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
-
- list_type list0101;
- VERIFY(list0101.begin() == list0101.end());
- VERIFY(list0101.size() == 0);
-
- // check type definitions -- will fail compile if missing
- typedef typename list_type::reference reference;
- typedef typename list_type::const_reference const_reference;
- typedef typename list_type::iterator iterator;
- typedef typename list_type::const_iterator const_iterator;
- typedef typename list_type::size_type size_type;
- typedef typename list_type::difference_type difference_type;
- typedef typename list_type::value_type value_type;
- typedef typename list_type::allocator_type allocator_type;
- typedef typename list_type::pointer pointer;
- typedef typename list_type::const_pointer const_pointer;
- typedef typename list_type::reverse_iterator reverse_iterator;
- typedef typename list_type::const_reverse_iterator const_reverse_iterator;
-
- // allocator checks?
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/1.h b/libstdc++-v3/testsuite/23_containers/list/cons/1.h
new file mode 100644
index 00000000000..2aa48be9146
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/1.h
@@ -0,0 +1,63 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// A nontrivial type.
+template<typename T>
+ struct A { };
+
+// Another nontrivial type
+struct B { };
+
+// Default constructor, basic properties
+//
+// This test verifies the following.
+// 23.2.2.1 explicit list(const a& = Allocator())
+// 23.1 (7) iterator behaviour of empty containers
+// 23.2.2 iterator begin()
+// 23.2.2 iterator end()
+// 23.2.2 size_type size() const
+// 23.2.2 existence of required typedefs
+//
+template<typename _Tp>
+void
+cons01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+
+ list_type list0101;
+ VERIFY(list0101.begin() == list0101.end());
+ VERIFY(list0101.size() == 0);
+
+ // check type definitions -- will fail compile if missing
+ typedef typename list_type::reference reference;
+ typedef typename list_type::const_reference const_reference;
+ typedef typename list_type::iterator iterator;
+ typedef typename list_type::const_iterator const_iterator;
+ typedef typename list_type::size_type size_type;
+ typedef typename list_type::difference_type difference_type;
+ typedef typename list_type::value_type value_type;
+ typedef typename list_type::allocator_type allocator_type;
+ typedef typename list_type::pointer pointer;
+ typedef typename list_type::const_pointer const_pointer;
+ typedef typename list_type::reverse_iterator reverse_iterator;
+ typedef typename list_type::const_reverse_iterator const_reverse_iterator;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/2.cc b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc
index a38cf7d1bba..86c59f383f8 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc
@@ -15,67 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "2.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// A nontrivial type.
-template<typename T>
- struct A { };
-
-// Another nontrivial type
-struct B { };
-
-// Fill constructor
-//
-// This test verifies the following.
-// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator())
-// 23.2.2 const_iterator begin() const
-// 23.2.2 const_iterator end() const
-// 23.2.2 size_type size() const
-//
-template<typename _Tp>
-void
-cons021()
-{
- bool test __attribute__((unused)) = true;
- const std::size_t LIST_SIZE = 5;
- const int INIT_VALUE = 7;
- std::size_t count;
-
- typedef _Tp list_type;
- typedef typename list_type::const_iterator const_iterator;
- const_iterator i;
-
- // default value
- list_type list0202(LIST_SIZE);
- for (i = list0202.begin(), count = 0;
- i != list0202.end();
- ++i, ++count)
- VERIFY(*i == 0);
- VERIFY(count == LIST_SIZE);
- VERIFY(list0202.size() == LIST_SIZE);
-
- // explicit value
- list_type list0203(LIST_SIZE, INIT_VALUE);
- for (i = list0203.begin(), count = 0;
- i != list0203.end();
- ++i, ++count)
- VERIFY(*i == INIT_VALUE);
- VERIFY(count == LIST_SIZE);
- VERIFY(list0203.size() == LIST_SIZE);
-}
-
-template<typename _Tp>
-void
-cons022()
-{
- // nontrivial value_type
- typedef _Tp list_type;
- const std::size_t LIST_SIZE = 5;
- list_type list0201(LIST_SIZE);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/2.h b/libstdc++-v3/testsuite/23_containers/list/cons/2.h
new file mode 100644
index 00000000000..eb32896e79a
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/2.h
@@ -0,0 +1,77 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// A nontrivial type.
+template<typename T>
+ struct A { };
+
+// Another nontrivial type
+struct B { };
+
+// Fill constructor
+//
+// This test verifies the following.
+// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator())
+// 23.2.2 const_iterator begin() const
+// 23.2.2 const_iterator end() const
+// 23.2.2 size_type size() const
+//
+template<typename _Tp>
+void
+cons021()
+{
+ bool test __attribute__((unused)) = true;
+ const std::size_t LIST_SIZE = 5;
+ const int INIT_VALUE = 7;
+ std::size_t count;
+
+ typedef _Tp list_type;
+ typedef typename list_type::const_iterator const_iterator;
+ const_iterator i;
+
+ // default value
+ list_type list0202(LIST_SIZE);
+ for (i = list0202.begin(), count = 0;
+ i != list0202.end();
+ ++i, ++count)
+ VERIFY(*i == 0);
+ VERIFY(count == LIST_SIZE);
+ VERIFY(list0202.size() == LIST_SIZE);
+
+ // explicit value
+ list_type list0203(LIST_SIZE, INIT_VALUE);
+ for (i = list0203.begin(), count = 0;
+ i != list0203.end();
+ ++i, ++count)
+ VERIFY(*i == INIT_VALUE);
+ VERIFY(count == LIST_SIZE);
+ VERIFY(list0203.size() == LIST_SIZE);
+}
+
+template<typename _Tp>
+void
+cons022()
+{
+ // nontrivial value_type
+ typedef _Tp list_type;
+ const std::size_t LIST_SIZE = 5;
+ list_type list0201(LIST_SIZE);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/3.cc b/libstdc++-v3/testsuite/23_containers/list/cons/3.cc
index b067ee17bc2..f373cc05d8a 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/3.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/3.cc
@@ -15,38 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "3.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// A nontrivial type convertible from an int
-struct C
-{
- C(int i) : i_(i) { }
- bool operator==(const C& rhs) { return i_ == rhs.i_; }
- int i_;
-};
-
-// Fill constructor disguised as a range constructor
-template<typename _Tp>
-void
-cons03()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
-
- const std::size_t LIST_SIZE = 5;
- const int INIT_VALUE = 7;
- std::size_t count = 0;
- list_type list0204(LIST_SIZE, INIT_VALUE);
- iterator i = list0204.begin();
- for (; i != list0204.end(); ++i, ++count)
- VERIFY(*i == INIT_VALUE);
- VERIFY(count == LIST_SIZE);
- VERIFY(list0204.size() == LIST_SIZE);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/3.h b/libstdc++-v3/testsuite/23_containers/list/cons/3.h
new file mode 100644
index 00000000000..983c24ca8ae
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/3.h
@@ -0,0 +1,48 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// A nontrivial type convertible from an int
+struct C
+{
+ C(int i) : i_(i) { }
+ bool operator==(const C& rhs) { return i_ == rhs.i_; }
+ int i_;
+};
+
+// Fill constructor disguised as a range constructor
+template<typename _Tp>
+void
+cons03()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+
+ const std::size_t LIST_SIZE = 5;
+ const int INIT_VALUE = 7;
+ std::size_t count = 0;
+ list_type list0204(LIST_SIZE, INIT_VALUE);
+ iterator i = list0204.begin();
+ for (; i != list0204.end(); ++i, ++count)
+ VERIFY(*i == INIT_VALUE);
+ VERIFY(count == LIST_SIZE);
+ VERIFY(list0204.size() == LIST_SIZE);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/4.cc b/libstdc++-v3/testsuite/23_containers/list/cons/4.cc
index 0dde9e9eaf4..d6b58be0481 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/4.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/4.cc
@@ -15,51 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "4.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// Range constructor
-//
-// This test verifies the following.
-// 23.2.2.1 template list(InputIterator f, InputIterator l,
-// const Allocator& a = Allocator())
-// 23.2.2 const_iterator begin() const
-// 23.2.2 const_iterator end() const
-// 23.2.2 size_type size() const
-//
-template<typename _Tp>
-void
-cons04()
-{
- 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 std::size_t N = sizeof(A) / sizeof(int);
- std::size_t count;
-
- typedef std::list<int> list_type;
- typedef typename list_type::const_iterator const_iterator;
- const_iterator i;
-
- // construct from a dissimilar range
- list_type list0301(A, A + N);
- for (i = list0301.begin(), count = 0;
- i != list0301.end();
- ++i, ++count)
- VERIFY(*i == A[count]);
- VERIFY(count == N);
- VERIFY(list0301.size() == N);
-
- // construct from a similar range
- list_type list0302(list0301.begin(), list0301.end());
- for (i = list0302.begin(), count = 0;
- i != list0302.end();
- ++i, ++count)
- VERIFY(*i == A[count]);
- VERIFY(count == N);
- VERIFY(list0302.size() == N);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/4.h b/libstdc++-v3/testsuite/23_containers/list/cons/4.h
new file mode 100644
index 00000000000..bf2e51c138d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/4.h
@@ -0,0 +1,61 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// Range constructor
+//
+// This test verifies the following.
+// 23.2.2.1 template list(InputIterator f, InputIterator l,
+// const Allocator& a = Allocator())
+// 23.2.2 const_iterator begin() const
+// 23.2.2 const_iterator end() const
+// 23.2.2 size_type size() const
+//
+template<typename _Tp>
+void
+cons04()
+{
+ 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 std::size_t N = sizeof(A) / sizeof(int);
+ std::size_t count;
+
+ typedef _Tp list_type;
+ typedef typename list_type::const_iterator const_iterator;
+ const_iterator i;
+
+ // construct from a dissimilar range
+ list_type list0301(A, A + N);
+ for (i = list0301.begin(), count = 0;
+ i != list0301.end();
+ ++i, ++count)
+ VERIFY(*i == A[count]);
+ VERIFY(count == N);
+ VERIFY(list0301.size() == N);
+
+ // construct from a similar range
+ list_type list0302(list0301.begin(), list0301.end());
+ for (i = list0302.begin(), count = 0;
+ i != list0302.end();
+ ++i, ++count)
+ VERIFY(*i == A[count]);
+ VERIFY(count == N);
+ VERIFY(list0302.size() == N);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/5.cc b/libstdc++-v3/testsuite/23_containers/list/cons/5.cc
index be8b5921aeb..de86dccd696 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/5.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/5.cc
@@ -15,41 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "5.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// Copy constructor
-//
-// This test verifies the following.
-// 23.2.2.1 list(const list& x)
-// 23.2.2 reverse_iterator rbegin()
-// 23.2.2 reverse_iterator rend()
-// 23.2.2 size_type size() const
-//
-template<typename _Tp>
-void
-cons05()
-{
- 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 std::size_t N = sizeof(A) / sizeof(int);
- int count;
-
- typedef _Tp list_type;
- typedef typename list_type::reverse_iterator reverse_iterator;
- reverse_iterator i;
- list_type list0401(A, A + N);
-
- list_type list0402(list0401);
- for (i = list0401.rbegin(), count = N - 1;
- i != list0401.rend();
- ++i, --count)
- VERIFY(*i == A[count]);
- VERIFY(count == -1);
- VERIFY(list0401.size() == N);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/5.h b/libstdc++-v3/testsuite/23_containers/list/cons/5.h
new file mode 100644
index 00000000000..5c273a322e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/5.h
@@ -0,0 +1,51 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// Copy constructor
+//
+// This test verifies the following.
+// 23.2.2.1 list(const list& x)
+// 23.2.2 reverse_iterator rbegin()
+// 23.2.2 reverse_iterator rend()
+// 23.2.2 size_type size() const
+//
+template<typename _Tp>
+void
+cons05()
+{
+ 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 std::size_t N = sizeof(A) / sizeof(int);
+ int count;
+
+ typedef _Tp list_type;
+ typedef typename list_type::reverse_iterator reverse_iterator;
+ reverse_iterator i;
+ list_type list0401(A, A + N);
+
+ list_type list0402(list0401);
+ for (i = list0401.rbegin(), count = N - 1;
+ i != list0401.rend();
+ ++i, --count)
+ VERIFY(*i == A[count]);
+ VERIFY(count == -1);
+ VERIFY(list0401.size() == N);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/6.cc b/libstdc++-v3/testsuite/23_containers/list/cons/6.cc
index c2ecc59de25..c1a2baedca2 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/6.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/6.cc
@@ -15,54 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "6.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// Range assign
-//
-// This test verifies the following.
-// 23.2.2.1 void assign(InputIterator f, InputIterator l)
-// 23.2.2 const_iterator begin() const
-// 23.2.2 const_iterator end() const
-// 23.2.2 size_type size() const
-//
-template<typename _Tp>
-void
-cons06()
-{
- 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[] = {101, 102, 103, 104, 105};
- const std::size_t N = sizeof(A) / sizeof(int);
- const std::size_t M = sizeof(B) / sizeof(int);
- std::size_t count;
-
- typedef _Tp list_type;
- typedef typename list_type::const_iterator const_iterator;
- const_iterator i;
-
- list_type list0501;
-
- // make it bigger
- list0501.assign(A, A + N);
- for (i = list0501.begin(), count = 0;
- i != list0501.end();
- ++i, ++count)
- VERIFY(*i == A[count]);
- VERIFY(count == N);
- VERIFY(list0501.size() == N);
-
- // make it smaller
- list0501.assign(B, B + M);
- for (i = list0501.begin(), count = 0;
- i != list0501.end();
- ++i, ++count)
- VERIFY(*i == B[count]);
- VERIFY(count == M);
- VERIFY(list0501.size() == M);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/6.h b/libstdc++-v3/testsuite/23_containers/list/cons/6.h
new file mode 100644
index 00000000000..b247e5563cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/6.h
@@ -0,0 +1,64 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// Range assign
+//
+// This test verifies the following.
+// 23.2.2.1 void assign(InputIterator f, InputIterator l)
+// 23.2.2 const_iterator begin() const
+// 23.2.2 const_iterator end() const
+// 23.2.2 size_type size() const
+//
+template<typename _Tp>
+void
+cons06()
+{
+ 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[] = {101, 102, 103, 104, 105};
+ const std::size_t N = sizeof(A) / sizeof(int);
+ const std::size_t M = sizeof(B) / sizeof(int);
+ std::size_t count;
+
+ typedef _Tp list_type;
+ typedef typename list_type::const_iterator const_iterator;
+ const_iterator i;
+
+ list_type list0501;
+
+ // make it bigger
+ list0501.assign(A, A + N);
+ for (i = list0501.begin(), count = 0;
+ i != list0501.end();
+ ++i, ++count)
+ VERIFY(*i == A[count]);
+ VERIFY(count == N);
+ VERIFY(list0501.size() == N);
+
+ // make it smaller
+ list0501.assign(B, B + M);
+ for (i = list0501.begin(), count = 0;
+ i != list0501.end();
+ ++i, ++count)
+ VERIFY(*i == B[count]);
+ VERIFY(count == M);
+ VERIFY(list0501.size() == M);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/7.cc b/libstdc++-v3/testsuite/23_containers/list/cons/7.cc
index 9a626a6234f..0f3de3c6763 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/7.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/7.cc
@@ -15,55 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "7.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// Fill assign
-//
-// This test verifies the following.
-// 23.2.2.1 void assign(size_type n, const T& v)
-// 23.2.2 const_iterator begin() const
-// 23.2.2 const_iterator end() const
-// 23.2.2 size_type size() const
-//
-template<typename _Tp>
-void
-cons07()
-{
- bool test __attribute__((unused)) = true;
- const std::size_t BIG_LIST_SIZE = 11;
- const int BIG_INIT_VALUE = 7;
- const std::size_t SMALL_LIST_SIZE = 5;
- const int SMALL_INIT_VALUE = 17;
- std::size_t count;
-
- typedef _Tp list_type;
- typedef typename list_type::const_iterator const_iterator;
- const_iterator i;
-
- list_type list0601;
- VERIFY(list0601.size() == 0);
-
- // make it bigger
- list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE);
- for (i = list0601.begin(), count = 0;
- i != list0601.end();
- ++i, ++count)
- VERIFY(*i == BIG_INIT_VALUE);
- VERIFY(count == BIG_LIST_SIZE);
- VERIFY(list0601.size() == BIG_LIST_SIZE);
-
- // make it shrink
- list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE);
- for (i = list0601.begin(), count = 0;
- i != list0601.end();
- ++i, ++count)
- VERIFY(*i == SMALL_INIT_VALUE);
- VERIFY(count == SMALL_LIST_SIZE);
- VERIFY(list0601.size() == SMALL_LIST_SIZE);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/7.h b/libstdc++-v3/testsuite/23_containers/list/cons/7.h
new file mode 100644
index 00000000000..1ebd7a5cfaa
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/7.h
@@ -0,0 +1,65 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// Fill assign
+//
+// This test verifies the following.
+// 23.2.2.1 void assign(size_type n, const T& v)
+// 23.2.2 const_iterator begin() const
+// 23.2.2 const_iterator end() const
+// 23.2.2 size_type size() const
+//
+template<typename _Tp>
+void
+cons07()
+{
+ bool test __attribute__((unused)) = true;
+ const std::size_t BIG_LIST_SIZE = 11;
+ const int BIG_INIT_VALUE = 7;
+ const std::size_t SMALL_LIST_SIZE = 5;
+ const int SMALL_INIT_VALUE = 17;
+ std::size_t count;
+
+ typedef _Tp list_type;
+ typedef typename list_type::const_iterator const_iterator;
+ const_iterator i;
+
+ list_type list0601;
+ VERIFY(list0601.size() == 0);
+
+ // make it bigger
+ list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE);
+ for (i = list0601.begin(), count = 0;
+ i != list0601.end();
+ ++i, ++count)
+ VERIFY(*i == BIG_INIT_VALUE);
+ VERIFY(count == BIG_LIST_SIZE);
+ VERIFY(list0601.size() == BIG_LIST_SIZE);
+
+ // make it shrink
+ list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE);
+ for (i = list0601.begin(), count = 0;
+ i != list0601.end();
+ ++i, ++count)
+ VERIFY(*i == SMALL_INIT_VALUE);
+ VERIFY(count == SMALL_LIST_SIZE);
+ VERIFY(list0601.size() == SMALL_LIST_SIZE);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/8.cc b/libstdc++-v3/testsuite/23_containers/list/cons/8.cc
index f93520c5406..16d888b4472 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/8.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/8.cc
@@ -15,41 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "8.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// A nontrivial type convertible from an int
-struct C
-{
- C(int i) : i_(i) { }
- bool operator==(const C& rhs) { return i_ == rhs.i_; }
- int i_;
-};
-
-// Fill Assignment disguised as a Range Assignment
-template<typename _Tp>
-void
-cons08()
-{
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
- bool test __attribute__((unused)) = true;
- const std::size_t LIST_SIZE = 5;
- const int INIT_VALUE = 7;
- std::size_t count = 0;
-
- list_type list0604;
- VERIFY(list0604.size() == 0);
-
- list0604.assign(LIST_SIZE, INIT_VALUE);
- iterator i = list0604.begin();
- for (; i != list0604.end(); ++i, ++count)
- VERIFY(*i == INIT_VALUE);
- VERIFY(count == LIST_SIZE);
- VERIFY(list0604.size() == LIST_SIZE);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/8.h b/libstdc++-v3/testsuite/23_containers/list/cons/8.h
new file mode 100644
index 00000000000..4aed16b81d9
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/8.h
@@ -0,0 +1,51 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// A nontrivial type convertible from an int
+struct C
+{
+ C(int i) : i_(i) { }
+ bool operator==(const C& rhs) { return i_ == rhs.i_; }
+ int i_;
+};
+
+// Fill Assignment disguised as a Range Assignment
+template<typename _Tp>
+void
+cons08()
+{
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+ bool test __attribute__((unused)) = true;
+ const std::size_t LIST_SIZE = 5;
+ const int INIT_VALUE = 7;
+ std::size_t count = 0;
+
+ list_type list0604;
+ VERIFY(list0604.size() == 0);
+
+ list0604.assign(LIST_SIZE, INIT_VALUE);
+ iterator i = list0604.begin();
+ for (; i != list0604.end(); ++i, ++count)
+ VERIFY(*i == INIT_VALUE);
+ VERIFY(count == LIST_SIZE);
+ VERIFY(list0604.size() == LIST_SIZE);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/9.cc b/libstdc++-v3/testsuite/23_containers/list/cons/9.cc
index 87cb0270c40..908454453a2 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/9.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/9.cc
@@ -15,49 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.1 list constructors, copy, and assignment
-
+#include "9.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// Assignment operator
-//
-// This test verifies the following.
-// 23.2.2 operator=(const list& x)
-// 23.2.2 iterator begin()
-// 23.2.2 iterator end()
-// 23.2.2 size_type size() const
-// 23.2.2 bool operator==(const list& x, const list& y)
-//
-template<typename _Tp>
-void
-cons09()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
-
- const int A[] = {701, 702, 703, 704, 705};
- const std::size_t N = sizeof(A) / sizeof(int);
- std::size_t count;
-
- iterator i;
-
- list_type list0701(A, A + N);
- VERIFY(list0701.size() == N);
-
- list_type list0702;
- VERIFY(list0702.size() == 0);
-
- list0702 = list0701;
- VERIFY(list0702.size() == N);
- for (i = list0702.begin(), count = 0;
- i != list0702.end();
- ++i, ++count)
- VERIFY(*i == A[count]);
- VERIFY(count == N);
- VERIFY(list0702 == list0701);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/9.h b/libstdc++-v3/testsuite/23_containers/list/cons/9.h
new file mode 100644
index 00000000000..90c3fd0540e
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/9.h
@@ -0,0 +1,59 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.1 list constructors, copy, and assignment
+
+#include <testsuite_hooks.h>
+
+// Assignment operator
+//
+// This test verifies the following.
+// 23.2.2 operator=(const list& x)
+// 23.2.2 iterator begin()
+// 23.2.2 iterator end()
+// 23.2.2 size_type size() const
+// 23.2.2 bool operator==(const list& x, const list& y)
+//
+template<typename _Tp>
+void
+cons09()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+
+ const int A[] = {701, 702, 703, 704, 705};
+ const std::size_t N = sizeof(A) / sizeof(int);
+ std::size_t count;
+
+ iterator i;
+
+ list_type list0701(A, A + N);
+ VERIFY(list0701.size() == N);
+
+ list_type list0702;
+ VERIFY(list0702.size() == 0);
+
+ list0702 = list0701;
+ VERIFY(list0702.size() == N);
+ for (i = list0702.begin(), count = 0;
+ i != list0702.end();
+ ++i, ++count)
+ VERIFY(*i == A[count]);
+ VERIFY(count == N);
+ VERIFY(list0702 == list0701);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc
index 82a47ade754..cb186d321cb 100644
--- a/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc
@@ -15,69 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+#include "clear_allocator.h"
#include <list>
-#include <ext/new_allocator.h>
-
-using namespace std;
-using __gnu_cxx::new_allocator;
-
-template<typename T>
- class clear_alloc : public new_allocator<T>
- {
- public:
-
- template <typename T1>
- struct rebind
- { typedef clear_alloc<T1> other; };
-
- virtual void clear() throw()
- { }
-
- clear_alloc() throw()
- { }
-
- clear_alloc(clear_alloc const&) throw() : new_allocator<T>()
- { }
-
- template<typename T1>
- clear_alloc(clear_alloc<T1> const&) throw()
- { }
-
- virtual ~clear_alloc() throw()
- { this->clear(); }
-
- T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0)
- {
- this->clear();
- return new_allocator<T>::allocate(n, hint);
- }
-
- void deallocate(T *ptr, typename new_allocator<T>::size_type n)
- {
- this->clear();
- new_allocator<T>::deallocate(ptr, n);
- }
- };
-
-template<typename Container>
- void Check_Container()
- {
- Container* pic = new Container;
- int x = 230;
-
- while (x--)
- {
- pic->push_back(x);
- }
-
- pic->get_allocator();
-
- // The following has led to infinite recursions or cores.
- pic->clear();
-
- delete pic;
- }
-
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h
new file mode 100644
index 00000000000..3a53751c962
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h
@@ -0,0 +1,78 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+#include <ext/new_allocator.h>
+
+using namespace std;
+using __gnu_cxx::new_allocator;
+
+template<typename T>
+ class clear_alloc : public new_allocator<T>
+ {
+ public:
+
+ template <typename T1>
+ struct rebind
+ { typedef clear_alloc<T1> other; };
+
+ virtual void clear() throw()
+ { }
+
+ clear_alloc() throw()
+ { }
+
+ clear_alloc(clear_alloc const&) throw() : new_allocator<T>()
+ { }
+
+ template<typename T1>
+ clear_alloc(clear_alloc<T1> const&) throw()
+ { }
+
+ virtual ~clear_alloc() throw()
+ { this->clear(); }
+
+ T* allocate(typename new_allocator<T>::size_type n, const void *hint = 0)
+ {
+ this->clear();
+ return new_allocator<T>::allocate(n, hint);
+ }
+
+ void deallocate(T *ptr, typename new_allocator<T>::size_type n)
+ {
+ this->clear();
+ new_allocator<T>::deallocate(ptr, n);
+ }
+ };
+
+template<typename Container>
+ void Check_Container()
+ {
+ Container* pic = new Container;
+ int x = 230;
+
+ while (x--)
+ {
+ pic->push_back(x);
+ }
+
+ pic->get_allocator();
+
+ // The following has led to infinite recursions or cores.
+ pic->clear();
+
+ delete pic;
+ }
diff --git a/libstdc++-v3/testsuite/23_containers/list/init-list.cc b/libstdc++-v3/testsuite/23_containers/list/init-list.cc
index 261ef084f09..db6bc3b6937 100644
--- a/libstdc++-v3/testsuite/23_containers/list/init-list.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/init-list.cc
@@ -1,3 +1,5 @@
+// { 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
@@ -16,56 +18,8 @@
// <http://www.gnu.org/licenses/>.
//
-// { dg-options "-std=gnu++0x" }
-
+#include "init-list.h"
#include <list>
-#include <testsuite_allocator.h>
-
-template<typename _Tp>
-bool
-init_list()
-{
- using namespace __gnu_test;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
-
- const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
- bool ok = true;
-
- tracker_allocator_counter::reset();
- {
- list_type c({ 2, 4, 1 });
- ok = check_construct_destroy("Construct from init-list", 3, 0) && ok;
- iterator i = c.begin();
- ok &= (*i++ == 2);
- ok &= (*i++ == 4);
- }
- ok = check_construct_destroy("Construct from init-list", 3, 3) && ok;
-
- {
- list_type c(arr10, arr10 + 10);
- tracker_allocator_counter::reset();
- iterator i = c.begin();
- ++i; ++i; ++i; ++i; ++i; ++i; ++i;
- c.insert(i, { 234, 42, 1 });
- ok = check_construct_destroy("Insert init-list", 3, 0) && ok;
- ok &= (*--i == 1);
- ok &= (*--i == 42);
- }
- ok = check_construct_destroy("Insert init-list", 3, 13) && ok;
-
- {
- list_type c;
- tracker_allocator_counter::reset();
- c = { 13, 0, 42 };
- ok = check_construct_destroy("Assign init-list", 3, 0) && ok;
- iterator i = c.begin();
- ok &= (*i++ == 13);
- }
- ok = check_construct_destroy("Assign init-list", 3, 3) && ok;
-
- return ok ? 0 : 1;
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/init-list.h b/libstdc++-v3/testsuite/23_containers/list/init-list.h
new file mode 100644
index 00000000000..a391ffdad67
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/init-list.h
@@ -0,0 +1,65 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <testsuite_allocator.h>
+
+template<typename _Tp>
+bool
+init_list()
+{
+ using namespace __gnu_test;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+
+ const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 };
+ bool ok = true;
+
+ tracker_allocator_counter::reset();
+ {
+ list_type c({ 2, 4, 1 });
+ ok = check_construct_destroy("Construct from init-list", 3, 0) && ok;
+ iterator i = c.begin();
+ ok &= (*i++ == 2);
+ ok &= (*i++ == 4);
+ }
+ ok = check_construct_destroy("Construct from init-list", 3, 3) && ok;
+
+ {
+ list_type c(arr10, arr10 + 10);
+ tracker_allocator_counter::reset();
+ iterator i = c.begin();
+ ++i; ++i; ++i; ++i; ++i; ++i; ++i;
+ c.insert(i, { 234, 42, 1 });
+ ok = check_construct_destroy("Insert init-list", 3, 0) && ok;
+ ok &= (*--i == 1);
+ ok &= (*--i == 42);
+ }
+ ok = check_construct_destroy("Insert init-list", 3, 13) && ok;
+
+ {
+ list_type c;
+ tracker_allocator_counter::reset();
+ c = { 13, 0, 42 };
+ ok = check_construct_destroy("Assign init-list", 3, 0) && ok;
+ iterator i = c.begin();
+ ok &= (*i++ == 13);
+ }
+ ok = check_construct_destroy("Assign init-list", 3, 3) && ok;
+
+ return ok ? 0 : 1;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/invalidation/1.cc b/libstdc++-v3/testsuite/23_containers/list/invalidation/1.cc
index 04267c253c7..7198e2402f0 100644
--- a/libstdc++-v3/testsuite/23_containers/list/invalidation/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/invalidation/1.cc
@@ -26,7 +26,7 @@ void test01()
{
using std::advance;
- bool test = true;
+ bool test __attribute__((unused)) = true;
typedef __gnu_debug::list<int> list_type;
list_type v1;
diff --git a/libstdc++-v3/testsuite/23_containers/list/invalidation/2.cc b/libstdc++-v3/testsuite/23_containers/list/invalidation/2.cc
index a141f2cdc82..5872936bba9 100644
--- a/libstdc++-v3/testsuite/23_containers/list/invalidation/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/invalidation/2.cc
@@ -26,7 +26,7 @@ void test02()
{
using std::advance;
- bool test = true;
+ bool test __attribute__((unused)) = true;
typedef __gnu_debug::list<int> list_type;
diff --git a/libstdc++-v3/testsuite/23_containers/list/invalidation/3.cc b/libstdc++-v3/testsuite/23_containers/list/invalidation/3.cc
index 770d4597484..0d4844793b8 100644
--- a/libstdc++-v3/testsuite/23_containers/list/invalidation/3.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/invalidation/3.cc
@@ -26,7 +26,7 @@ void test03()
{
using std::advance;
- bool test = true;
+ bool test __attribute__((unused)) = true;
typedef __gnu_debug::list<int> list_type;
list_type v(20, 42);
diff --git a/libstdc++-v3/testsuite/23_containers/list/invalidation/4.cc b/libstdc++-v3/testsuite/23_containers/list/invalidation/4.cc
index 11e4394fa7d..a5c9219a2be 100644
--- a/libstdc++-v3/testsuite/23_containers/list/invalidation/4.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/invalidation/4.cc
@@ -26,7 +26,7 @@ void test04()
{
using std::advance;
- bool test = true;
+ bool test __attribute__((unused)) = true;
typedef __gnu_debug::list<int> list_type;
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc
index b1c85f0511c..cf8c20a6578 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc
@@ -15,103 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.3 list modifiers [lib.list.modifiers]
-
+#include "1.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// range and fill insert/erase + clear
-// missing: o fill insert disguised as a range insert in all its variants
-// o exception effects
-template<typename _Tp>
-void
-modifiers1()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
- typedef typename list_type::value_type value_type;
-
- list_type list0301;
- value_type::reset();
-
- // fill insert at beginning of list / empty list
- list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11]
- VERIFY(list0301.size() == 3);
- VERIFY(value_type::copyCount() == 3);
-
- // save iterators to verify post-insert validity
- iterator b = list0301.begin();
- iterator m = list0301.end(); --m;
- iterator e = list0301.end();
-
- // fill insert at end of list
- value_type::reset();
- list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13]
- VERIFY(list0301.size() == 6);
- VERIFY(value_type::copyCount() == 3);
- VERIFY(b == list0301.begin() && b->id() == 11);
- VERIFY(e == list0301.end());
- VERIFY(m->id() == 11);
-
- // fill insert in the middle of list
- ++m;
- value_type::reset();
- list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13]
- VERIFY(list0301.size() == 9);
- VERIFY(value_type::copyCount() == 3);
- VERIFY(b == list0301.begin() && b->id() == 11);
- VERIFY(e == list0301.end());
- VERIFY(m->id() == 13);
-
- // single erase
- value_type::reset();
- m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
- VERIFY(list0301.size() == 8);
- VERIFY(value_type::dtorCount() == 1);
- VERIFY(b == list0301.begin() && b->id() == 11);
- VERIFY(e == list0301.end());
- VERIFY(m->id() == 13);
-
- // range erase
- value_type::reset();
- m = list0301.erase(list0301.begin(), m); // should be [13 13]
- VERIFY(list0301.size() == 2);
- VERIFY(value_type::dtorCount() == 6);
- VERIFY(m->id() == 13);
-
- // range fill at beginning
- const int A[] = {321, 322, 333};
- const int N = sizeof(A) / sizeof(int);
- value_type::reset();
- b = list0301.begin();
- list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
- VERIFY(list0301.size() == 5);
- VERIFY(value_type::copyCount() == 3);
- VERIFY(m->id() == 13);
-
- // range fill at end
- value_type::reset();
- list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
- VERIFY(list0301.size() == 8);
- VERIFY(value_type::copyCount() == 3);
- VERIFY(e == list0301.end());
- VERIFY(m->id() == 13);
-
- // range fill in middle
- value_type::reset();
- list0301.insert(m, A, A + N);
- VERIFY(list0301.size() == 11);
- VERIFY(value_type::copyCount() == 3);
- VERIFY(e == list0301.end());
- VERIFY(m->id() == 13);
-
- value_type::reset();
- list0301.clear();
- VERIFY(list0301.size() == 0);
- VERIFY(value_type::dtorCount() == 11);
- VERIFY(e == list0301.end());
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h
new file mode 100644
index 00000000000..f26fd885485
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h
@@ -0,0 +1,113 @@
+// Copyright (C) 2001, 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.3 list modifiers [lib.list.modifiers]
+
+#include <testsuite_hooks.h>
+
+// range and fill insert/erase + clear
+// missing: o fill insert disguised as a range insert in all its variants
+// o exception effects
+template<typename _Tp>
+void
+modifiers1()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+ typedef typename list_type::value_type value_type;
+
+ list_type list0301;
+ value_type::reset();
+
+ // fill insert at beginning of list / empty list
+ list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11]
+ VERIFY(list0301.size() == 3);
+ VERIFY(value_type::copyCount() == 3);
+
+ // save iterators to verify post-insert validity
+ iterator b = list0301.begin();
+ iterator m = list0301.end(); --m;
+ iterator e = list0301.end();
+
+ // fill insert at end of list
+ value_type::reset();
+ list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13]
+ VERIFY(list0301.size() == 6);
+ VERIFY(value_type::copyCount() == 3);
+ VERIFY(b == list0301.begin() && b->id() == 11);
+ VERIFY(e == list0301.end());
+ VERIFY(m->id() == 11);
+
+ // fill insert in the middle of list
+ ++m;
+ value_type::reset();
+ list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13]
+ VERIFY(list0301.size() == 9);
+ VERIFY(value_type::copyCount() == 3);
+ VERIFY(b == list0301.begin() && b->id() == 11);
+ VERIFY(e == list0301.end());
+ VERIFY(m->id() == 13);
+
+ // single erase
+ value_type::reset();
+ m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13]
+ VERIFY(list0301.size() == 8);
+ VERIFY(value_type::dtorCount() == 1);
+ VERIFY(b == list0301.begin() && b->id() == 11);
+ VERIFY(e == list0301.end());
+ VERIFY(m->id() == 13);
+
+ // range erase
+ value_type::reset();
+ m = list0301.erase(list0301.begin(), m); // should be [13 13]
+ VERIFY(list0301.size() == 2);
+ VERIFY(value_type::dtorCount() == 6);
+ VERIFY(m->id() == 13);
+
+ // range fill at beginning
+ const int A[] = {321, 322, 333};
+ const int N = sizeof(A) / sizeof(int);
+ value_type::reset();
+ b = list0301.begin();
+ list0301.insert(b, A, A + N); // should be [321 322 333 13 13]
+ VERIFY(list0301.size() == 5);
+ VERIFY(value_type::copyCount() == 3);
+ VERIFY(m->id() == 13);
+
+ // range fill at end
+ value_type::reset();
+ list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333]
+ VERIFY(list0301.size() == 8);
+ VERIFY(value_type::copyCount() == 3);
+ VERIFY(e == list0301.end());
+ VERIFY(m->id() == 13);
+
+ // range fill in middle
+ value_type::reset();
+ list0301.insert(m, A, A + N);
+ VERIFY(list0301.size() == 11);
+ VERIFY(value_type::copyCount() == 3);
+ VERIFY(e == list0301.end());
+ VERIFY(m->id() == 13);
+
+ value_type::reset();
+ list0301.clear();
+ VERIFY(list0301.size() == 0);
+ VERIFY(value_type::dtorCount() == 11);
+ VERIFY(e == list0301.end());
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc
index da39397d098..ee9b54923df 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc
@@ -15,76 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.3 list modifiers [lib.list.modifiers]
-
+#include "2.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// general single insert/erase + swap
-template<typename _Tp>
-void
-modifiers2()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::value_type value_type;
- typedef typename list_type::iterator iterator;
- typedef typename list_type::const_iterator const_iterator;
-
- list_type list0201;
- value_type::reset();
-
- list0201.insert(list0201.begin(), value_type(1)); // list should be [1]
- VERIFY(list0201.size() == 1);
- VERIFY(value_type::copyCount() == 1);
-
- list0201.insert(list0201.end(), value_type(2)); // list should be [1 2]
- VERIFY(list0201.size() == 2);
- VERIFY(value_type::copyCount() == 2);
-
- iterator i = list0201.begin();
- const_iterator j = i;
- VERIFY(i->id() == 1); ++i;
- VERIFY(i->id() == 2);
-
- list0201.insert(i, value_type(3)); // list should be [1 3 2]
- VERIFY(list0201.size() == 3);
- VERIFY(value_type::copyCount() == 3);
-
- const_iterator k = i;
- VERIFY(i->id() == 2); --i;
- VERIFY(i->id() == 3); --i;
- VERIFY(i->id() == 1);
- VERIFY(j->id() == 1);
-
- ++i; // will point to '3'
- value_type::reset();
- list0201.erase(i); // should be [1 2]
- VERIFY(list0201.size() == 2);
- VERIFY(value_type::dtorCount() == 1);
- VERIFY(k->id() == 2);
- VERIFY(j->id() == 1);
-
- list_type list0202;
- value_type::reset();
- VERIFY(list0202.size() == 0);
- VERIFY(value_type::copyCount() == 0);
- VERIFY(value_type::dtorCount() == 0);
-
- // member swap
- list0202.swap(list0201);
- VERIFY(list0201.size() == 0);
- VERIFY(list0202.size() == 2);
- VERIFY(value_type::copyCount() == 0);
- VERIFY(value_type::dtorCount() == 0);
-
- // specialized swap
- swap(list0201, list0202);
- VERIFY(list0201.size() == 2);
- VERIFY(list0202.size() == 0);
- VERIFY(value_type::copyCount() == 0);
- VERIFY(value_type::dtorCount() == 0);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h
new file mode 100644
index 00000000000..64a348769e2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h
@@ -0,0 +1,86 @@
+// Copyright (C) 2001, 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.3 list modifiers [lib.list.modifiers]
+
+#include <testsuite_hooks.h>
+
+// general single insert/erase + swap
+template<typename _Tp>
+void
+modifiers2()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::value_type value_type;
+ typedef typename list_type::iterator iterator;
+ typedef typename list_type::const_iterator const_iterator;
+
+ list_type list0201;
+ value_type::reset();
+
+ list0201.insert(list0201.begin(), value_type(1)); // list should be [1]
+ VERIFY(list0201.size() == 1);
+ VERIFY(value_type::copyCount() == 1);
+
+ list0201.insert(list0201.end(), value_type(2)); // list should be [1 2]
+ VERIFY(list0201.size() == 2);
+ VERIFY(value_type::copyCount() == 2);
+
+ iterator i = list0201.begin();
+ const_iterator j = i;
+ VERIFY(i->id() == 1); ++i;
+ VERIFY(i->id() == 2);
+
+ list0201.insert(i, value_type(3)); // list should be [1 3 2]
+ VERIFY(list0201.size() == 3);
+ VERIFY(value_type::copyCount() == 3);
+
+ const_iterator k = i;
+ VERIFY(i->id() == 2); --i;
+ VERIFY(i->id() == 3); --i;
+ VERIFY(i->id() == 1);
+ VERIFY(j->id() == 1);
+
+ ++i; // will point to '3'
+ value_type::reset();
+ list0201.erase(i); // should be [1 2]
+ VERIFY(list0201.size() == 2);
+ VERIFY(value_type::dtorCount() == 1);
+ VERIFY(k->id() == 2);
+ VERIFY(j->id() == 1);
+
+ list_type list0202;
+ value_type::reset();
+ VERIFY(list0202.size() == 0);
+ VERIFY(value_type::copyCount() == 0);
+ VERIFY(value_type::dtorCount() == 0);
+
+ // member swap
+ list0202.swap(list0201);
+ VERIFY(list0201.size() == 0);
+ VERIFY(list0202.size() == 2);
+ VERIFY(value_type::copyCount() == 0);
+ VERIFY(value_type::dtorCount() == 0);
+
+ // specialized swap
+ swap(list0201, list0202);
+ VERIFY(list0201.size() == 2);
+ VERIFY(list0202.size() == 0);
+ VERIFY(value_type::copyCount() == 0);
+ VERIFY(value_type::dtorCount() == 0);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc
index b6a41e3dc45..8454c3f46fa 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc
@@ -15,108 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.3 list modifiers [lib.list.modifiers]
-
+#include "3.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// This test verifies the following.
-//
-// 23.2.2.3 void push_front(const T& x)
-// 23.2.2.3 void push_back(const T& x)
-// 23.2.2.3 (1) iterator and reference non-invalidation
-// 23.2.2.3 (1) exception effects
-// 23.2.2.3 (2) complexity requirements
-//
-// 23.2.2.3 void pop_front()
-// 23.2.2.3 void pop_back()
-// 23.2.2.3 (3) iterator and reference non-invalidation
-// 23.2.2.3 (5) complexity requirements
-//
-// 23.2.2 const_iterator begin() const
-// 23.2.2 iterator end()
-// 23.2.2 const_reverse_iterator rbegin() const
-// 23.2.2 _reference front()
-// 23.2.2 const_reference front() const
-// 23.2.2 reference back()
-// 23.2.2 const_reference back() const
-//
-template<typename _Tp>
-void
-modifiers3()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
- typedef typename list_type::value_type value_type;
- typedef typename list_type::const_iterator const_iterator;
- typedef typename list_type::const_reverse_iterator const_reverse_iterator;
-
- list_type list0101;
- const_iterator i;
- const_reverse_iterator j;
- iterator k;
- value_type::reset();
-
- list0101.push_back(value_type(1)); // list should be [1]
- VERIFY(list0101.size() == 1);
- VERIFY(value_type::copyCount() == 1);
-
- k = list0101.end();
- --k;
- VERIFY(k->id() == 1);
- VERIFY(k->id() == list0101.front().id());
- VERIFY(k->id() == list0101.back().id());
-
- list0101.push_front(value_type(2)); // list should be [2 1]
- VERIFY(list0101.size() == 2);
- VERIFY(value_type::copyCount() == 2);
- VERIFY(k->id() == 1);
-
- list0101.push_back(value_type(3)); // list should be [2 1 3]
- VERIFY(list0101.size() == 3);
- VERIFY(value_type::copyCount() == 3);
- VERIFY(k->id() == 1);
-
- try
- {
- list0101.push_back(value_type(4, true));
- VERIFY(false);
- }
- catch (...)
- {
- VERIFY(list0101.size() == 3);
- VERIFY(value_type::copyCount() == 4);
- }
-
- i = list0101.begin();
- VERIFY(i->id() == 2);
- VERIFY(i->id() == list0101.front().id());
-
- j = list0101.rbegin();
- VERIFY(j->id() == 3);
- VERIFY(j->id() == list0101.back().id());
-
- ++i;
- VERIFY(i->id() == 1);
-
- ++j;
- VERIFY(j->id() == 1);
-
- value_type::reset();
-
- list0101.pop_back(); // list should be [2 1]
- VERIFY(list0101.size() == 2);
- VERIFY(value_type::dtorCount() == 1);
- VERIFY(i->id() == 1);
- VERIFY(k->id() == 1);
-
- list0101.pop_front(); // list should be [1]
- VERIFY(list0101.size() == 1);
- VERIFY(value_type::dtorCount() == 2);
- VERIFY(i->id() == 1);
- VERIFY(k->id() == 1);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h
new file mode 100644
index 00000000000..43e5c58ec60
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h
@@ -0,0 +1,118 @@
+// Copyright (C) 2001, 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.3 list modifiers [lib.list.modifiers]
+
+#include <testsuite_hooks.h>
+
+// This test verifies the following.
+//
+// 23.2.2.3 void push_front(const T& x)
+// 23.2.2.3 void push_back(const T& x)
+// 23.2.2.3 (1) iterator and reference non-invalidation
+// 23.2.2.3 (1) exception effects
+// 23.2.2.3 (2) complexity requirements
+//
+// 23.2.2.3 void pop_front()
+// 23.2.2.3 void pop_back()
+// 23.2.2.3 (3) iterator and reference non-invalidation
+// 23.2.2.3 (5) complexity requirements
+//
+// 23.2.2 const_iterator begin() const
+// 23.2.2 iterator end()
+// 23.2.2 const_reverse_iterator rbegin() const
+// 23.2.2 _reference front()
+// 23.2.2 const_reference front() const
+// 23.2.2 reference back()
+// 23.2.2 const_reference back() const
+//
+template<typename _Tp>
+void
+modifiers3()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+ typedef typename list_type::value_type value_type;
+ typedef typename list_type::const_iterator const_iterator;
+ typedef typename list_type::const_reverse_iterator const_reverse_iterator;
+
+ list_type list0101;
+ const_iterator i;
+ const_reverse_iterator j;
+ iterator k;
+ value_type::reset();
+
+ list0101.push_back(value_type(1)); // list should be [1]
+ VERIFY(list0101.size() == 1);
+ VERIFY(value_type::copyCount() == 1);
+
+ k = list0101.end();
+ --k;
+ VERIFY(k->id() == 1);
+ VERIFY(k->id() == list0101.front().id());
+ VERIFY(k->id() == list0101.back().id());
+
+ list0101.push_front(value_type(2)); // list should be [2 1]
+ VERIFY(list0101.size() == 2);
+ VERIFY(value_type::copyCount() == 2);
+ VERIFY(k->id() == 1);
+
+ list0101.push_back(value_type(3)); // list should be [2 1 3]
+ VERIFY(list0101.size() == 3);
+ VERIFY(value_type::copyCount() == 3);
+ VERIFY(k->id() == 1);
+
+ try
+ {
+ list0101.push_back(value_type(4, true));
+ VERIFY(false);
+ }
+ catch (...)
+ {
+ VERIFY(list0101.size() == 3);
+ VERIFY(value_type::copyCount() == 4);
+ }
+
+ i = list0101.begin();
+ VERIFY(i->id() == 2);
+ VERIFY(i->id() == list0101.front().id());
+
+ j = list0101.rbegin();
+ VERIFY(j->id() == 3);
+ VERIFY(j->id() == list0101.back().id());
+
+ ++i;
+ VERIFY(i->id() == 1);
+
+ ++j;
+ VERIFY(j->id() == 1);
+
+ value_type::reset();
+
+ list0101.pop_back(); // list should be [2 1]
+ VERIFY(list0101.size() == 2);
+ VERIFY(value_type::dtorCount() == 1);
+ VERIFY(i->id() == 1);
+ VERIFY(k->id() == 1);
+
+ list0101.pop_front(); // list should be [1]
+ VERIFY(list0101.size() == 1);
+ VERIFY(value_type::dtorCount() == 2);
+ VERIFY(i->id() == 1);
+ VERIFY(k->id() == 1);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc
index e108288586e..e9195ddbc64 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc
@@ -1,3 +1,5 @@
+// { dg-require-time "" }
+
// Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -15,82 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.3 list modifiers [lib.list.modifiers]
-
-// { dg-require-time "" }
-
+#include "25288.h"
#include <list>
-#include <testsuite_hooks.h>
-#include <ext/throw_allocator.h>
-
-// libstdc++/25288
-template<typename _Tp>
-void insert1()
-{
- bool test __attribute__((unused)) = true;
-
- typedef _Tp list_type;
- typedef typename _Tp::value_type value_type;
- typedef typename _Tp::allocator_type allocator_type;
- typedef typename _Tp::size_type size_type;
-
- for (int j = 0; j < 10; ++j)
- for (int i = 0; i < 10; ++i)
- {
- allocator_type alloc1;
- typename allocator_type::never_adjustor adjust1;
- list_type list1(alloc1);
-
- for (int k = 0; k < j; ++k)
- list1.push_back(value_type(-(k + 1)));
-
- try
- {
- typename allocator_type::always_adjustor adjust2;
- list1.insert(list1.begin(), 10, 99);
- VERIFY( false );
- }
- catch (__gnu_cxx::forced_exception_error&)
- {
- VERIFY( true );
- }
- catch (...)
- {
- __throw_exception_again;
- }
-
- VERIFY( list1.size() == size_type(j) );
- VERIFY( list1.size() == 0 || list1.back() == -j );
- VERIFY( list1.size() == 0 || list1.front() == -1 );
-
- allocator_type alloc2;
- list_type list2(alloc2);
-
- const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-
- for (int k = 0; k < j; ++k)
- list2.push_back(-(k + 1));
-
- try
- {
- typename allocator_type::always_adjustor adjust3;
- list2.insert(list2.begin(), data, data + 10);
- VERIFY( false );
- }
- catch (__gnu_cxx::forced_exception_error&)
- {
- VERIFY( true );
- }
- catch (...)
- {
- VERIFY( false );
- }
-
- VERIFY( list2.size() == size_type(j) );
- VERIFY( list2.size() == 0 || list2.back() == -j );
- VERIFY( list2.size() == 0 || list2.front() == -1 );
- }
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h
new file mode 100644
index 00000000000..c3ec6628f3d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h
@@ -0,0 +1,90 @@
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.3 list modifiers [lib.list.modifiers]
+
+#include <testsuite_hooks.h>
+#include <ext/throw_allocator.h>
+
+// libstdc++/25288
+template<typename _Tp>
+void insert1()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp list_type;
+ typedef typename _Tp::value_type value_type;
+ typedef typename _Tp::allocator_type allocator_type;
+ typedef typename _Tp::size_type size_type;
+
+ for (int j = 0; j < 10; ++j)
+ for (int i = 0; i < 10; ++i)
+ {
+ allocator_type alloc1;
+ typename allocator_type::never_adjustor adjust1;
+ list_type list1(alloc1);
+
+ for (int k = 0; k < j; ++k)
+ list1.push_back(value_type(-(k + 1)));
+
+ try
+ {
+ typename allocator_type::always_adjustor adjust2;
+ list1.insert(list1.begin(), 10, 99);
+ VERIFY( false );
+ }
+ catch (__gnu_cxx::forced_exception_error&)
+ {
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ __throw_exception_again;
+ }
+
+ VERIFY( list1.size() == size_type(j) );
+ VERIFY( list1.size() == 0 || list1.back() == -j );
+ VERIFY( list1.size() == 0 || list1.front() == -1 );
+
+ allocator_type alloc2;
+ list_type list2(alloc2);
+
+ const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+ for (int k = 0; k < j; ++k)
+ list2.push_back(-(k + 1));
+
+ try
+ {
+ typename allocator_type::always_adjustor adjust3;
+ list2.insert(list2.begin(), data, data + 10);
+ VERIFY( false );
+ }
+ catch (__gnu_cxx::forced_exception_error&)
+ {
+ VERIFY( true );
+ }
+ catch (...)
+ {
+ VERIFY( false );
+ }
+
+ VERIFY( list2.size() == size_type(j) );
+ VERIFY( list2.size() == 0 || list2.back() == -j );
+ VERIFY( list2.size() == 0 || list2.front() == -1 );
+ }
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc
index c66ead57c76..d9bd9a2194e 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc
@@ -15,12 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
+#include "1.h"
#include <list>
-#include <testsuite_hooks.h>
-
-struct T { int i; };
-
-int swap_calls;
namespace std
{
@@ -30,41 +26,6 @@ namespace std
{ ++swap_calls; }
}
-// Should use list specialization for swap.
-template<typename _Tp>
-void
-swap11()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
-
- list_type A;
- list_type B;
- swap_calls = 0;
- std::swap(A, B);
- VERIFY(1 == swap_calls);
-}
-
-// Should use list specialization for swap.
-template<typename _Tp>
-void
-swap12()
-{
- using namespace std;
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
-
- list_type A;
- list_type B;
- swap_calls = 0;
- swap(A, B);
- VERIFY(1 == swap_calls);
-}
-
-#if !__GXX_WEAK__ && _MT_ALLOCATOR_H
-template class __gnu_cxx::__mt_alloc<std::_List_node<T> >;
-#endif
-
// See c++/13658 for background info.
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h
new file mode 100644
index 00000000000..64619b42470
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2004, 2009 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+struct T { int i; };
+
+int swap_calls;
+
+// Should use list specialization for swap.
+template<typename _Tp>
+void
+swap11()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+
+ list_type A;
+ list_type B;
+ swap_calls = 0;
+ std::swap(A, B);
+ VERIFY(1 == swap_calls);
+}
+
+// Should use list specialization for swap.
+template<typename _Tp>
+void
+swap12()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+
+ list_type A;
+ list_type B;
+ swap_calls = 0;
+ swap(A, B);
+ VERIFY(1 == swap_calls);
+}
+
+#if !__GXX_WEAK__ && _MT_ALLOCATOR_H
+template class __gnu_cxx::__mt_alloc<std::_List_node<T> >;
+#endif
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc
index e31c0fb5924..7bd75a39e3c 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc
@@ -17,115 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.3 list::swap
-
+#include "2.h"
#include <list>
-#include <testsuite_hooks.h>
-#include <testsuite_allocator.h>
-
-// uneq_allocator as a non-empty allocator.
-template<typename _Tp>
-void
-swap2()
-{
- bool test __attribute__((unused)) = true;
- using namespace std;
-
- typedef _Tp list_type;
- typedef typename list_type::allocator_type allocator_type;
- typedef typename list_type::size_type size_type;
-
- const char title01[] = "Rivers of sand";
- const char title02[] = "Concret PH";
- const char title03[] = "Sonatas and Interludes for Prepared Piano";
- const char title04[] = "never as tired as when i'm waking up";
-
- const size_t N1 = sizeof(title01);
- const size_t N2 = sizeof(title02);
- const size_t N3 = sizeof(title03);
- const size_t N4 = sizeof(title04);
-
- size_type size01, size02;
-
- allocator_type alloc01(1);
-
- list_type lis01(alloc01);
- size01 = lis01.size();
- list_type lis02(alloc01);
- size02 = lis02.size();
-
- lis01.swap(lis02);
- VERIFY( lis01.size() == size02 );
- VERIFY( lis01.empty() );
- VERIFY( lis02.size() == size01 );
- VERIFY( lis02.empty() );
-
- list_type lis03(alloc01);
- size01 = lis03.size();
- list_type lis04(title02, title02 + N2, alloc01);
- size02 = lis04.size();
-
- lis03.swap(lis04);
- VERIFY( lis03.size() == size02 );
- VERIFY( equal(lis03.begin(), lis03.end(), title02) );
- VERIFY( lis04.size() == size01 );
- VERIFY( lis04.empty() );
-
- list_type lis05(title01, title01 + N1, alloc01);
- size01 = lis05.size();
- list_type lis06(title02, title02 + N2, alloc01);
- size02 = lis06.size();
-
- lis05.swap(lis06);
- VERIFY( lis05.size() == size02 );
- VERIFY( equal(lis05.begin(), lis05.end(), title02) );
- VERIFY( lis06.size() == size01 );
- VERIFY( equal(lis06.begin(), lis06.end(), title01) );
-
- list_type lis07(title01, title01 + N1, alloc01);
- size01 = lis07.size();
- list_type lis08(title03, title03 + N3, alloc01);
- size02 = lis08.size();
-
- lis07.swap(lis08);
- VERIFY( lis07.size() == size02 );
- VERIFY( equal(lis07.begin(), lis07.end(), title03) );
- VERIFY( lis08.size() == size01 );
- VERIFY( equal(lis08.begin(), lis08.end(), title01) );
-
- list_type lis09(title03, title03 + N3, alloc01);
- size01 = lis09.size();
- list_type lis10(title04, title04 + N4, alloc01);
- size02 = lis10.size();
-
- lis09.swap(lis10);
- VERIFY( lis09.size() == size02 );
- VERIFY( equal(lis09.begin(), lis09.end(), title04) );
- VERIFY( lis10.size() == size01 );
- VERIFY( equal(lis10.begin(), lis10.end(), title03) );
-
- list_type lis11(title04, title04 + N4, alloc01);
- size01 = lis11.size();
- list_type lis12(title01, title01 + N1, alloc01);
- size02 = lis12.size();
-
- lis11.swap(lis12);
- VERIFY( lis11.size() == size02 );
- VERIFY( equal(lis11.begin(), lis11.end(), title01) );
- VERIFY( lis12.size() == size01 );
- VERIFY( equal(lis12.begin(), lis12.end(), title04) );
-
- list_type lis13(title03, title03 + N3, alloc01);
- size01 = lis13.size();
- list_type lis14(title03, title03 + N3, alloc01);
- size02 = lis14.size();
-
- lis13.swap(lis14);
- VERIFY( lis13.size() == size02 );
- VERIFY( equal(lis13.begin(), lis13.end(), title03) );
- VERIFY( lis14.size() == size01 );
- VERIFY( equal(lis14.begin(), lis14.end(), title03) );
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h
new file mode 100644
index 00000000000..2cd68f60c7a
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h
@@ -0,0 +1,127 @@
+// 2005-12-20 Paolo Carlini <pcarlini@suse.de>
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.3 list::swap
+
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// uneq_allocator as a non-empty allocator.
+template<typename _Tp>
+void
+swap2()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ typedef _Tp list_type;
+ typedef typename list_type::allocator_type allocator_type;
+ typedef typename list_type::size_type size_type;
+
+ const char title01[] = "Rivers of sand";
+ const char title02[] = "Concret PH";
+ const char title03[] = "Sonatas and Interludes for Prepared Piano";
+ const char title04[] = "never as tired as when i'm waking up";
+
+ const size_t N1 = sizeof(title01);
+ const size_t N2 = sizeof(title02);
+ const size_t N3 = sizeof(title03);
+ const size_t N4 = sizeof(title04);
+
+ size_type size01, size02;
+
+ allocator_type alloc01(1);
+
+ list_type lis01(alloc01);
+ size01 = lis01.size();
+ list_type lis02(alloc01);
+ size02 = lis02.size();
+
+ lis01.swap(lis02);
+ VERIFY( lis01.size() == size02 );
+ VERIFY( lis01.empty() );
+ VERIFY( lis02.size() == size01 );
+ VERIFY( lis02.empty() );
+
+ list_type lis03(alloc01);
+ size01 = lis03.size();
+ list_type lis04(title02, title02 + N2, alloc01);
+ size02 = lis04.size();
+
+ lis03.swap(lis04);
+ VERIFY( lis03.size() == size02 );
+ VERIFY( equal(lis03.begin(), lis03.end(), title02) );
+ VERIFY( lis04.size() == size01 );
+ VERIFY( lis04.empty() );
+
+ list_type lis05(title01, title01 + N1, alloc01);
+ size01 = lis05.size();
+ list_type lis06(title02, title02 + N2, alloc01);
+ size02 = lis06.size();
+
+ lis05.swap(lis06);
+ VERIFY( lis05.size() == size02 );
+ VERIFY( equal(lis05.begin(), lis05.end(), title02) );
+ VERIFY( lis06.size() == size01 );
+ VERIFY( equal(lis06.begin(), lis06.end(), title01) );
+
+ list_type lis07(title01, title01 + N1, alloc01);
+ size01 = lis07.size();
+ list_type lis08(title03, title03 + N3, alloc01);
+ size02 = lis08.size();
+
+ lis07.swap(lis08);
+ VERIFY( lis07.size() == size02 );
+ VERIFY( equal(lis07.begin(), lis07.end(), title03) );
+ VERIFY( lis08.size() == size01 );
+ VERIFY( equal(lis08.begin(), lis08.end(), title01) );
+
+ list_type lis09(title03, title03 + N3, alloc01);
+ size01 = lis09.size();
+ list_type lis10(title04, title04 + N4, alloc01);
+ size02 = lis10.size();
+
+ lis09.swap(lis10);
+ VERIFY( lis09.size() == size02 );
+ VERIFY( equal(lis09.begin(), lis09.end(), title04) );
+ VERIFY( lis10.size() == size01 );
+ VERIFY( equal(lis10.begin(), lis10.end(), title03) );
+
+ list_type lis11(title04, title04 + N4, alloc01);
+ size01 = lis11.size();
+ list_type lis12(title01, title01 + N1, alloc01);
+ size02 = lis12.size();
+
+ lis11.swap(lis12);
+ VERIFY( lis11.size() == size02 );
+ VERIFY( equal(lis11.begin(), lis11.end(), title01) );
+ VERIFY( lis12.size() == size01 );
+ VERIFY( equal(lis12.begin(), lis12.end(), title04) );
+
+ list_type lis13(title03, title03 + N3, alloc01);
+ size01 = lis13.size();
+ list_type lis14(title03, title03 + N3, alloc01);
+ size02 = lis14.size();
+
+ lis13.swap(lis14);
+ VERIFY( lis13.size() == size02 );
+ VERIFY( equal(lis13.begin(), lis13.end(), title03) );
+ VERIFY( lis14.size() == size01 );
+ VERIFY( equal(lis14.begin(), lis14.end(), title03) );
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc
index c0e0f65bf64..f994e9b4ae1 100644
--- a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc
@@ -17,144 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.3 list::swap
-
+#include "3.h"
#include <list>
-#include <testsuite_hooks.h>
-#include <testsuite_allocator.h>
-
-// uneq_allocator, two different personalities.
-template<typename _Tp>
-void
-swap3()
-{
- bool test __attribute__((unused)) = true;
- using namespace std;
-
- typedef _Tp list_type;
- typedef typename list_type::allocator_type allocator_type;
- typedef typename list_type::size_type size_type;
-
- const char title01[] = "Rivers of sand";
- const char title02[] = "Concret PH";
- const char title03[] = "Sonatas and Interludes for Prepared Piano";
- const char title04[] = "never as tired as when i'm waking up";
-
- const size_t N1 = sizeof(title01);
- const size_t N2 = sizeof(title02);
- const size_t N3 = sizeof(title03);
- const size_t N4 = sizeof(title04);
-
- size_type size01, size02;
-
- allocator_type alloc01(1), alloc02(2);
- int personality01, personality02;
-
- list_type lis01(alloc01);
- size01 = lis01.size();
- personality01 = lis01.get_allocator().get_personality();
- list_type lis02(alloc02);
- size02 = lis02.size();
- personality02 = lis02.get_allocator().get_personality();
-
- lis01.swap(lis02);
- VERIFY( lis01.size() == size02 );
- VERIFY( lis01.empty() );
- VERIFY( lis02.size() == size01 );
- VERIFY( lis02.empty() );
- VERIFY( lis01.get_allocator().get_personality() == personality02 );
- VERIFY( lis02.get_allocator().get_personality() == personality01 );
-
- list_type lis03(alloc02);
- size01 = lis03.size();
- personality01 = lis03.get_allocator().get_personality();
- list_type lis04(title02, title02 + N2, alloc01);
- size02 = lis04.size();
- personality02 = lis04.get_allocator().get_personality();
-
- lis03.swap(lis04);
- VERIFY( lis03.size() == size02 );
- VERIFY( equal(lis03.begin(), lis03.end(), title02) );
- VERIFY( lis04.size() == size01 );
- VERIFY( lis04.empty() );
- VERIFY( lis03.get_allocator().get_personality() == personality02 );
- VERIFY( lis04.get_allocator().get_personality() == personality01 );
-
- list_type lis05(title01, title01 + N1, alloc01);
- size01 = lis05.size();
- personality01 = lis05.get_allocator().get_personality();
- list_type lis06(title02, title02 + N2, alloc02);
- size02 = lis06.size();
- personality02 = lis06.get_allocator().get_personality();
-
- lis05.swap(lis06);
- VERIFY( lis05.size() == size02 );
- VERIFY( equal(lis05.begin(), lis05.end(), title02) );
- VERIFY( lis06.size() == size01 );
- VERIFY( equal(lis06.begin(), lis06.end(), title01) );
- VERIFY( lis05.get_allocator().get_personality() == personality02 );
- VERIFY( lis06.get_allocator().get_personality() == personality01 );
-
- list_type lis07(title01, title01 + N1, alloc02);
- size01 = lis07.size();
- personality01 = lis07.get_allocator().get_personality();
- list_type lis08(title03, title03 + N3, alloc01);
- size02 = lis08.size();
- personality02 = lis08.get_allocator().get_personality();
-
- lis07.swap(lis08);
- VERIFY( lis07.size() == size02 );
- VERIFY( equal(lis07.begin(), lis07.end(), title03) );
- VERIFY( lis08.size() == size01 );
- VERIFY( equal(lis08.begin(), lis08.end(), title01) );
- VERIFY( lis07.get_allocator().get_personality() == personality02 );
- VERIFY( lis08.get_allocator().get_personality() == personality01 );
-
- list_type lis09(title03, title03 + N3, alloc01);
- size01 = lis09.size();
- personality01 = lis09.get_allocator().get_personality();
- list_type lis10(title04, title04 + N4, alloc02);
- size02 = lis10.size();
- personality02 = lis10.get_allocator().get_personality();
-
- lis09.swap(lis10);
- VERIFY( lis09.size() == size02 );
- VERIFY( equal(lis09.begin(), lis09.end(), title04) );
- VERIFY( lis10.size() == size01 );
- VERIFY( equal(lis10.begin(), lis10.end(), title03) );
- VERIFY( lis09.get_allocator().get_personality() == personality02 );
- VERIFY( lis10.get_allocator().get_personality() == personality01 );
-
- list_type lis11(title04, title04 + N4, alloc02);
- size01 = lis11.size();
- personality01 = lis11.get_allocator().get_personality();
- list_type lis12(title01, title01 + N1, alloc01);
- size02 = lis12.size();
- personality02 = lis12.get_allocator().get_personality();
-
- lis11.swap(lis12);
- VERIFY( lis11.size() == size02 );
- VERIFY( equal(lis11.begin(), lis11.end(), title01) );
- VERIFY( lis12.size() == size01 );
- VERIFY( equal(lis12.begin(), lis12.end(), title04) );
- VERIFY( lis11.get_allocator().get_personality() == personality02 );
- VERIFY( lis12.get_allocator().get_personality() == personality01 );
-
- list_type lis13(title03, title03 + N3, alloc01);
- size01 = lis13.size();
- personality01 = lis13.get_allocator().get_personality();
- list_type lis14(title03, title03 + N3, alloc02);
- size02 = lis14.size();
- personality02 = lis14.get_allocator().get_personality();
-
- lis13.swap(lis14);
- VERIFY( lis13.size() == size02 );
- VERIFY( equal(lis13.begin(), lis13.end(), title03) );
- VERIFY( lis14.size() == size01 );
- VERIFY( equal(lis14.begin(), lis14.end(), title03) );
- VERIFY( lis13.get_allocator().get_personality() == personality02 );
- VERIFY( lis14.get_allocator().get_personality() == personality01 );
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h
new file mode 100644
index 00000000000..b4f2cd097d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h
@@ -0,0 +1,156 @@
+// 2005-12-20 Paolo Carlini <pcarlini@suse.de>
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.3 list::swap
+
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// uneq_allocator, two different personalities.
+template<typename _Tp>
+void
+swap3()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ typedef _Tp list_type;
+ typedef typename list_type::allocator_type allocator_type;
+ typedef typename list_type::size_type size_type;
+
+ const char title01[] = "Rivers of sand";
+ const char title02[] = "Concret PH";
+ const char title03[] = "Sonatas and Interludes for Prepared Piano";
+ const char title04[] = "never as tired as when i'm waking up";
+
+ const size_t N1 = sizeof(title01);
+ const size_t N2 = sizeof(title02);
+ const size_t N3 = sizeof(title03);
+ const size_t N4 = sizeof(title04);
+
+ size_type size01, size02;
+
+ allocator_type alloc01(1), alloc02(2);
+ int personality01, personality02;
+
+ list_type lis01(alloc01);
+ size01 = lis01.size();
+ personality01 = lis01.get_allocator().get_personality();
+ list_type lis02(alloc02);
+ size02 = lis02.size();
+ personality02 = lis02.get_allocator().get_personality();
+
+ lis01.swap(lis02);
+ VERIFY( lis01.size() == size02 );
+ VERIFY( lis01.empty() );
+ VERIFY( lis02.size() == size01 );
+ VERIFY( lis02.empty() );
+ VERIFY( lis01.get_allocator().get_personality() == personality02 );
+ VERIFY( lis02.get_allocator().get_personality() == personality01 );
+
+ list_type lis03(alloc02);
+ size01 = lis03.size();
+ personality01 = lis03.get_allocator().get_personality();
+ list_type lis04(title02, title02 + N2, alloc01);
+ size02 = lis04.size();
+ personality02 = lis04.get_allocator().get_personality();
+
+ lis03.swap(lis04);
+ VERIFY( lis03.size() == size02 );
+ VERIFY( equal(lis03.begin(), lis03.end(), title02) );
+ VERIFY( lis04.size() == size01 );
+ VERIFY( lis04.empty() );
+ VERIFY( lis03.get_allocator().get_personality() == personality02 );
+ VERIFY( lis04.get_allocator().get_personality() == personality01 );
+
+ list_type lis05(title01, title01 + N1, alloc01);
+ size01 = lis05.size();
+ personality01 = lis05.get_allocator().get_personality();
+ list_type lis06(title02, title02 + N2, alloc02);
+ size02 = lis06.size();
+ personality02 = lis06.get_allocator().get_personality();
+
+ lis05.swap(lis06);
+ VERIFY( lis05.size() == size02 );
+ VERIFY( equal(lis05.begin(), lis05.end(), title02) );
+ VERIFY( lis06.size() == size01 );
+ VERIFY( equal(lis06.begin(), lis06.end(), title01) );
+ VERIFY( lis05.get_allocator().get_personality() == personality02 );
+ VERIFY( lis06.get_allocator().get_personality() == personality01 );
+
+ list_type lis07(title01, title01 + N1, alloc02);
+ size01 = lis07.size();
+ personality01 = lis07.get_allocator().get_personality();
+ list_type lis08(title03, title03 + N3, alloc01);
+ size02 = lis08.size();
+ personality02 = lis08.get_allocator().get_personality();
+
+ lis07.swap(lis08);
+ VERIFY( lis07.size() == size02 );
+ VERIFY( equal(lis07.begin(), lis07.end(), title03) );
+ VERIFY( lis08.size() == size01 );
+ VERIFY( equal(lis08.begin(), lis08.end(), title01) );
+ VERIFY( lis07.get_allocator().get_personality() == personality02 );
+ VERIFY( lis08.get_allocator().get_personality() == personality01 );
+
+ list_type lis09(title03, title03 + N3, alloc01);
+ size01 = lis09.size();
+ personality01 = lis09.get_allocator().get_personality();
+ list_type lis10(title04, title04 + N4, alloc02);
+ size02 = lis10.size();
+ personality02 = lis10.get_allocator().get_personality();
+
+ lis09.swap(lis10);
+ VERIFY( lis09.size() == size02 );
+ VERIFY( equal(lis09.begin(), lis09.end(), title04) );
+ VERIFY( lis10.size() == size01 );
+ VERIFY( equal(lis10.begin(), lis10.end(), title03) );
+ VERIFY( lis09.get_allocator().get_personality() == personality02 );
+ VERIFY( lis10.get_allocator().get_personality() == personality01 );
+
+ list_type lis11(title04, title04 + N4, alloc02);
+ size01 = lis11.size();
+ personality01 = lis11.get_allocator().get_personality();
+ list_type lis12(title01, title01 + N1, alloc01);
+ size02 = lis12.size();
+ personality02 = lis12.get_allocator().get_personality();
+
+ lis11.swap(lis12);
+ VERIFY( lis11.size() == size02 );
+ VERIFY( equal(lis11.begin(), lis11.end(), title01) );
+ VERIFY( lis12.size() == size01 );
+ VERIFY( equal(lis12.begin(), lis12.end(), title04) );
+ VERIFY( lis11.get_allocator().get_personality() == personality02 );
+ VERIFY( lis12.get_allocator().get_personality() == personality01 );
+
+ list_type lis13(title03, title03 + N3, alloc01);
+ size01 = lis13.size();
+ personality01 = lis13.get_allocator().get_personality();
+ list_type lis14(title03, title03 + N3, alloc02);
+ size02 = lis14.size();
+ personality02 = lis14.get_allocator().get_personality();
+
+ lis13.swap(lis14);
+ VERIFY( lis13.size() == size02 );
+ VERIFY( equal(lis13.begin(), lis13.end(), title03) );
+ VERIFY( lis14.size() == size01 );
+ VERIFY( equal(lis14.begin(), lis14.end(), title03) );
+ VERIFY( lis13.get_allocator().get_personality() == personality02 );
+ VERIFY( lis14.get_allocator().get_personality() == personality01 );
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/moveable.cc b/libstdc++-v3/testsuite/23_containers/list/moveable.cc
index dc245b1ca00..fbe06634e6f 100644
--- a/libstdc++-v3/testsuite/23_containers/list/moveable.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/moveable.cc
@@ -17,31 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// NOTE: This makes use of the fact that we know how moveable
-// is implemented on list (via swap). If the implementation changed
-// this test may begin to fail.
-
+#include "moveable.h"
#include <list>
-#include <utility>
-#include <testsuite_hooks.h>
-
-template<typename _Tp>
- void
- test_moveable()
- {
- bool test __attribute__((unused)) = true;
-
- typedef _Tp list_type;
-
- list_type a,b;
- a.push_back(1);
- b = std::move(a);
- VERIFY( b.size() == 1 && *b.begin() == 1 && a.size() == 0 );
-
- list_type c(std::move(b));
- VERIFY( c.size() == 1 && *c.begin() == 1 );
- VERIFY( b.size() == 0 );
- }
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/moveable.h b/libstdc++-v3/testsuite/23_containers/list/moveable.h
new file mode 100644
index 00000000000..1f11d6221e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/moveable.h
@@ -0,0 +1,41 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on list (via swap). If the implementation changed
+// this test may begin to fail.
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+template<typename _Tp>
+ void
+ test_moveable()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp list_type;
+
+ list_type a,b;
+ a.push_back(1);
+ b = std::move(a);
+ VERIFY( b.size() == 1 && *b.begin() == 1 && a.size() == 0 );
+
+ list_type c(std::move(b));
+ VERIFY( c.size() == 1 && *c.begin() == 1 );
+ VERIFY( b.size() == 0 );
+ }
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/1.cc b/libstdc++-v3/testsuite/23_containers/list/operations/1.cc
index d44e1c70612..2c98213e2a5 100644
--- a/libstdc++-v3/testsuite/23_containers/list/operations/1.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/1.cc
@@ -15,58 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.4 list operations [lib.list.ops]
-
+#include "1.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// splice(p, x) + remove + reverse
-template<typename _Tp>
-void
-operations01()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
-
- const int K = 417;
- const int A[] = {1, 2, 3, 4, 5};
- const int B[] = {K, K, K, K, K};
- const std::size_t N = sizeof(A) / sizeof(int);
- const std::size_t M = sizeof(B) / sizeof(int);
-
- list_type list0101(A, A + N);
- list_type list0102(B, B + M);
- iterator p = list0101.begin();
-
- VERIFY(list0101.size() == N);
- VERIFY(list0102.size() == M);
-
- ++p;
- list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5]
- VERIFY(list0101.size() == N + M);
- VERIFY(list0102.size() == 0);
-
- // remove range from middle
- list0101.remove(K);
- VERIFY(list0101.size() == N);
-
- // remove first element
- list0101.remove(1);
- VERIFY(list0101.size() == N - 1);
-
- // remove last element
- list0101.remove(5);
- VERIFY(list0101.size() == N - 2);
-
- // reverse
- list0101.reverse();
- p = list0101.begin();
- VERIFY(*p == 4); ++p;
- VERIFY(*p == 3); ++p;
- VERIFY(*p == 2); ++p;
- VERIFY(p == list0101.end());
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/1.h b/libstdc++-v3/testsuite/23_containers/list/operations/1.h
new file mode 100644
index 00000000000..2f3f9df9465
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/1.h
@@ -0,0 +1,68 @@
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.4 list operations [lib.list.ops]
+
+#include <testsuite_hooks.h>
+
+// splice(p, x) + remove + reverse
+template<typename _Tp>
+void
+operations01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+
+ const int K = 417;
+ const int A[] = {1, 2, 3, 4, 5};
+ const int B[] = {K, K, K, K, K};
+ const std::size_t N = sizeof(A) / sizeof(int);
+ const std::size_t M = sizeof(B) / sizeof(int);
+
+ list_type list0101(A, A + N);
+ list_type list0102(B, B + M);
+ iterator p = list0101.begin();
+
+ VERIFY(list0101.size() == N);
+ VERIFY(list0102.size() == M);
+
+ ++p;
+ list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5]
+ VERIFY(list0101.size() == N + M);
+ VERIFY(list0102.size() == 0);
+
+ // remove range from middle
+ list0101.remove(K);
+ VERIFY(list0101.size() == N);
+
+ // remove first element
+ list0101.remove(1);
+ VERIFY(list0101.size() == N - 1);
+
+ // remove last element
+ list0101.remove(5);
+ VERIFY(list0101.size() == N - 2);
+
+ // reverse
+ list0101.reverse();
+ p = list0101.begin();
+ VERIFY(*p == 4); ++p;
+ VERIFY(*p == 3); ++p;
+ VERIFY(*p == 2); ++p;
+ VERIFY(p == list0101.end());
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/2.cc b/libstdc++-v3/testsuite/23_containers/list/operations/2.cc
index 743b176b38f..100066fc29b 100644
--- a/libstdc++-v3/testsuite/23_containers/list/operations/2.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/2.cc
@@ -15,44 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.4 list operations [lib.list.ops]
-
+#include "2.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// splice(p, x, i) + remove_if + operator==
-template<typename _Tp>
-void
-operations02()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
-
- const int A[] = {1, 2, 3, 4, 5};
- const int B[] = {2, 1, 3, 4, 5};
- const int C[] = {1, 3, 4, 5, 2};
- const int N = sizeof(A) / sizeof(int);
- list_type list0201(A, A + N);
- list_type list0202(A, A + N);
- list_type list0203(B, B + N);
- list_type list0204(C, C + N);
- iterator i = list0201.begin();
-
- // result should be unchanged
- list0201.splice(list0201.begin(), list0201, i);
- VERIFY(list0201 == list0202);
-
- // result should be [2 1 3 4 5]
- ++i;
- list0201.splice(list0201.begin(), list0201, i);
- VERIFY(list0201 != list0202);
- VERIFY(list0201 == list0203);
-
- // result should be [1 3 4 5 2]
- list0201.splice(list0201.end(), list0201, i);
- VERIFY(list0201 == list0204);
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/2.h b/libstdc++-v3/testsuite/23_containers/list/operations/2.h
new file mode 100644
index 00000000000..8eb3da4e780
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/2.h
@@ -0,0 +1,54 @@
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.4 list operations [lib.list.ops]
+
+#include <testsuite_hooks.h>
+
+// splice(p, x, i) + remove_if + operator==
+template<typename _Tp>
+void
+operations02()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+
+ const int A[] = {1, 2, 3, 4, 5};
+ const int B[] = {2, 1, 3, 4, 5};
+ const int C[] = {1, 3, 4, 5, 2};
+ const int N = sizeof(A) / sizeof(int);
+ list_type list0201(A, A + N);
+ list_type list0202(A, A + N);
+ list_type list0203(B, B + N);
+ list_type list0204(C, C + N);
+ iterator i = list0201.begin();
+
+ // result should be unchanged
+ list0201.splice(list0201.begin(), list0201, i);
+ VERIFY(list0201 == list0202);
+
+ // result should be [2 1 3 4 5]
+ ++i;
+ list0201.splice(list0201.begin(), list0201, i);
+ VERIFY(list0201 != list0202);
+ VERIFY(list0201 == list0203);
+
+ // result should be [1 3 4 5 2]
+ list0201.splice(list0201.end(), list0201, i);
+ VERIFY(list0201 == list0204);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/3.cc b/libstdc++-v3/testsuite/23_containers/list/operations/3.cc
index 83d00133c49..53570b4a694 100644
--- a/libstdc++-v3/testsuite/23_containers/list/operations/3.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/3.cc
@@ -15,58 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.4 list operations [lib.list.ops]
-
+#include "3.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// splice(p, x, f, l) + sort + merge + unique
-template<typename _Tp>
-void
-operations03()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
- typedef typename list_type::iterator iterator;
-
- const int A[] = {103, 203, 603, 303, 403, 503};
- const int B[] = {417, 417, 417, 417, 417};
- const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
- const int F[] = {103, 203, 303, 403, 417, 417, 503, 603};
- const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603};
- const int D[] = {103, 203, 303, 403, 417, 503, 603};
- const int N = sizeof(A) / sizeof(int);
- const int M = sizeof(B) / sizeof(int);
- const int P = sizeof(C) / sizeof(int);
- const int Q = sizeof(D) / sizeof(int);
- const int R = sizeof(E) / sizeof(int);
-
- list_type list0301(A, A + N);
- list_type list0302(B, B + M);
- list_type list0303(C, C + P);
- list_type list0304(D, D + Q);
- list_type list0305(E, E + R);
- list_type list0306(F, F + R);
- iterator p = list0301.begin();
- iterator q = list0302.begin();
-
- ++p; ++q; ++q;
- list0301.splice(p, list0302, list0302.begin(), q);
- VERIFY(list0301 == list0305);
- VERIFY(list0301.size() == N + 2);
- VERIFY(list0302.size() == M - 2);
-
- list0301.sort();
- VERIFY(list0301 == list0306);
-
- list0301.merge(list0302);
- VERIFY(list0301.size() == N + M);
- VERIFY(list0302.size() == 0);
- VERIFY(list0301 == list0303);
-
- list0301.unique();
- VERIFY(list0301 == list0304);
-}
int main(void)
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/3.h b/libstdc++-v3/testsuite/23_containers/list/operations/3.h
new file mode 100644
index 00000000000..4d28daea12b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/3.h
@@ -0,0 +1,68 @@
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.4 list operations [lib.list.ops]
+
+#include <testsuite_hooks.h>
+
+// splice(p, x, f, l) + sort + merge + unique
+template<typename _Tp>
+void
+operations03()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+ typedef typename list_type::iterator iterator;
+
+ const int A[] = {103, 203, 603, 303, 403, 503};
+ const int B[] = {417, 417, 417, 417, 417};
+ const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
+ const int F[] = {103, 203, 303, 403, 417, 417, 503, 603};
+ const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603};
+ const int D[] = {103, 203, 303, 403, 417, 503, 603};
+ const int N = sizeof(A) / sizeof(int);
+ const int M = sizeof(B) / sizeof(int);
+ const int P = sizeof(C) / sizeof(int);
+ const int Q = sizeof(D) / sizeof(int);
+ const int R = sizeof(E) / sizeof(int);
+
+ list_type list0301(A, A + N);
+ list_type list0302(B, B + M);
+ list_type list0303(C, C + P);
+ list_type list0304(D, D + Q);
+ list_type list0305(E, E + R);
+ list_type list0306(F, F + R);
+ iterator p = list0301.begin();
+ iterator q = list0302.begin();
+
+ ++p; ++q; ++q;
+ list0301.splice(p, list0302, list0302.begin(), q);
+ VERIFY(list0301 == list0305);
+ VERIFY(list0301.size() == N + 2);
+ VERIFY(list0302.size() == M - 2);
+
+ list0301.sort();
+ VERIFY(list0301 == list0306);
+
+ list0301.merge(list0302);
+ VERIFY(list0301.size() == N + M);
+ VERIFY(list0302.size() == 0);
+ VERIFY(list0301 == list0303);
+
+ list0301.unique();
+ VERIFY(list0301 == list0304);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/4.cc b/libstdc++-v3/testsuite/23_containers/list/operations/4.cc
index 37b983a39a2..a220b9b331f 100644
--- a/libstdc++-v3/testsuite/23_containers/list/operations/4.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/4.cc
@@ -15,81 +15,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.4 list operations [lib.list.ops]
-
+#include "4.h"
#include <list>
-#include <testsuite_hooks.h>
-
-// A comparison predicate to order by rightmost digit. Tracks call
-// counts for performance checks.
-struct CompLastLt
-{
- bool operator()(const int x, const int y)
- { ++itsCount; return x % 10 < y % 10; }
- static int count() { return itsCount; }
- static void reset() { itsCount = 0; }
- static int itsCount;
-};
-
-int CompLastLt::itsCount;
-
-struct CompLastEq
-{
- bool operator()(const int x, const int y)
- { ++itsCount; return x % 10 == y % 10; }
- static int count() { return itsCount; }
- static void reset() { itsCount = 0; }
- static int itsCount;
-};
-
-int CompLastEq::itsCount;
-
-// sort(pred) + merge(pred) + unique(pred)
-// also checks performance requirements
-template<typename _Tp>
-void
-operations04()
-{
- bool test __attribute__((unused)) = true;
- typedef _Tp list_type;
-
- const int A[] = {1, 2, 3, 4, 5, 6};
- const int B[] = {12, 15, 13, 14, 11};
- const int C[] = {11, 12, 13, 14, 15};
- const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6};
- const int N = sizeof(A) / sizeof(int);
- const int M = sizeof(B) / sizeof(int);
- const int Q = sizeof(D) / sizeof(int);
-
- list_type list0401(A, A + N);
- list_type list0402(B, B + M);
- list_type list0403(C, C + M);
- list_type list0404(D, D + Q);
- list_type list0405(A, A + N);
-
- // sort B
- CompLastLt lt;
-
- CompLastLt::reset();
- list0402.sort(lt);
- VERIFY(list0402 == list0403);
-
- CompLastLt::reset();
- list0401.merge(list0402, lt);
- VERIFY(list0401 == list0404);
-#ifndef _GLIBCXX_DEBUG
- VERIFY(lt.count() <= (N + M - 1));
-#endif
-
- CompLastEq eq;
-
- CompLastEq::reset();
- list0401.unique(eq);
- VERIFY(list0401 == list0405);
-#ifndef _GLIBCXX_DEBUG
- VERIFY(eq.count() == (N + M - 1));
-#endif
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/4.h b/libstdc++-v3/testsuite/23_containers/list/operations/4.h
new file mode 100644
index 00000000000..0a3ea4d234d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/4.h
@@ -0,0 +1,92 @@
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.4 list operations [lib.list.ops]
+
+#include <testsuite_hooks.h>
+
+// A comparison predicate to order by rightmost digit. Tracks call
+// counts for performance checks.
+struct CompLastLt
+{
+ bool operator()(const int x, const int y)
+ { ++itsCount; return x % 10 < y % 10; }
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+ static int itsCount;
+};
+
+int CompLastLt::itsCount;
+
+struct CompLastEq
+{
+ bool operator()(const int x, const int y)
+ { ++itsCount; return x % 10 == y % 10; }
+ static int count() { return itsCount; }
+ static void reset() { itsCount = 0; }
+ static int itsCount;
+};
+
+int CompLastEq::itsCount;
+
+// sort(pred) + merge(pred) + unique(pred)
+// also checks performance requirements
+template<typename _Tp>
+void
+operations04()
+{
+ bool test __attribute__((unused)) = true;
+ typedef _Tp list_type;
+
+ const int A[] = {1, 2, 3, 4, 5, 6};
+ const int B[] = {12, 15, 13, 14, 11};
+ const int C[] = {11, 12, 13, 14, 15};
+ const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6};
+ const int N = sizeof(A) / sizeof(int);
+ const int M = sizeof(B) / sizeof(int);
+ const int Q = sizeof(D) / sizeof(int);
+
+ list_type list0401(A, A + N);
+ list_type list0402(B, B + M);
+ list_type list0403(C, C + M);
+ list_type list0404(D, D + Q);
+ list_type list0405(A, A + N);
+
+ // sort B
+ CompLastLt lt;
+
+ CompLastLt::reset();
+ list0402.sort(lt);
+ VERIFY(list0402 == list0403);
+
+ CompLastLt::reset();
+ list0401.merge(list0402, lt);
+ VERIFY(list0401 == list0404);
+#ifndef _GLIBCXX_DEBUG
+ VERIFY(lt.count() <= (N + M - 1));
+#endif
+
+ CompLastEq eq;
+
+ CompLastEq::reset();
+ list0401.unique(eq);
+ VERIFY(list0401 == list0405);
+#ifndef _GLIBCXX_DEBUG
+ VERIFY(eq.count() == (N + M - 1));
+#endif
+}
+
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/5.cc b/libstdc++-v3/testsuite/23_containers/list/operations/5.cc
index ae1939c8824..ad99c27ae42 100644
--- a/libstdc++-v3/testsuite/23_containers/list/operations/5.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/5.cc
@@ -17,122 +17,8 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 23.2.2.4 list operations [lib.list.ops]
-
+#include "5.h"
#include <list>
-#include <stdexcept>
-#include <testsuite_hooks.h>
-#include <testsuite_allocator.h>
-
-// Check the splice (and merge) bits of N1599.
-template<typename _Tp>
-void
-operations05()
-{
- bool test __attribute__((unused)) = true;
-
- typedef _Tp list_type;
- typedef typename list_type::allocator_type allocator_type;
-
- const int data1[] = {1, 2, 3, 4, 5};
- const int data2[] = {6, 7, 8, 9, 10};
- const size_t N1 = sizeof(data1) / sizeof(int);
- const size_t N2 = sizeof(data2) / sizeof(int);
-
- allocator_type alloc01(1), alloc02(2);
-
- list_type l01(data1, data1 + N1, alloc01);
- const list_type l01_ref = l01;
-
- list_type l02(data2, data2 + N2, alloc02);
- const list_type l02_ref = l02;
-
- bool catched = false;
-
- try
- {
- l01.splice(l01.begin(), l02);
- }
- catch(std::runtime_error&)
- {
- catched = true;
- }
- catch(...)
- {
- VERIFY( false );
- }
- VERIFY( catched );
- VERIFY( l01 == l01_ref );
- VERIFY( l02 == l02_ref );
-
- catched = false;
- try
- {
- l01.splice(l01.begin(), l02, l02.begin());
- }
- catch(std::runtime_error&)
- {
- catched = true;
- }
- catch(...)
- {
- VERIFY( false );
- }
- VERIFY( catched );
- VERIFY( l01 == l01_ref );
- VERIFY( l02 == l02_ref );
-
- catched = false;
- try
- {
- l01.splice(l01.begin(), l02, l02.begin(), l02.end());
- }
- catch(std::runtime_error&)
- {
- catched = true;
- }
- catch(...)
- {
- VERIFY( false );
- }
- VERIFY( catched );
- VERIFY( l01 == l01_ref );
- VERIFY( l02 == l02_ref );
-
- catched = false;
- try
- {
- l01.merge(l02);
- }
- catch(std::runtime_error&)
- {
- catched = true;
- }
- catch(...)
- {
- VERIFY( false );
- }
- VERIFY( catched );
- VERIFY( l01 == l01_ref );
- VERIFY( l02 == l02_ref );
-
- catched = false;
- try
- {
- l01.merge(l02, std::less<int>());
- }
- catch(std::runtime_error&)
- {
- catched = true;
- }
- catch(...)
- {
- VERIFY( false );
- }
- VERIFY( catched );
- VERIFY( l01 == l01_ref );
- VERIFY( l02 == l02_ref );
-}
int main()
{
diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/5.h b/libstdc++-v3/testsuite/23_containers/list/operations/5.h
new file mode 100644
index 00000000000..2b54d5195ff
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/operations/5.h
@@ -0,0 +1,134 @@
+// 2006-01-19 Paolo Carlini <pcarlini@suse.de>
+
+// 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 Pred the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 23.2.2.4 list operations [lib.list.ops]
+
+#include <stdexcept>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+// Check the splice (and merge) bits of N1599.
+template<typename _Tp>
+void
+operations05()
+{
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp list_type;
+ typedef typename list_type::allocator_type allocator_type;
+
+ const int data1[] = {1, 2, 3, 4, 5};
+ const int data2[] = {6, 7, 8, 9, 10};
+ const size_t N1 = sizeof(data1) / sizeof(int);
+ const size_t N2 = sizeof(data2) / sizeof(int);
+
+ allocator_type alloc01(1), alloc02(2);
+
+ list_type l01(data1, data1 + N1, alloc01);
+ const list_type l01_ref = l01;
+
+ list_type l02(data2, data2 + N2, alloc02);
+ const list_type l02_ref = l02;
+
+ bool catched = false;
+
+ try
+ {
+ l01.splice(l01.begin(), l02);
+ }
+ catch(std::runtime_error&)
+ {
+ catched = true;
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ VERIFY( catched );
+ VERIFY( l01 == l01_ref );
+ VERIFY( l02 == l02_ref );
+
+ catched = false;
+ try
+ {
+ l01.splice(l01.begin(), l02, l02.begin());
+ }
+ catch(std::runtime_error&)
+ {
+ catched = true;
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ VERIFY( catched );
+ VERIFY( l01 == l01_ref );
+ VERIFY( l02 == l02_ref );
+
+ catched = false;
+ try
+ {
+ l01.splice(l01.begin(), l02, l02.begin(), l02.end());
+ }
+ catch(std::runtime_error&)
+ {
+ catched = true;
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ VERIFY( catched );
+ VERIFY( l01 == l01_ref );
+ VERIFY( l02 == l02_ref );
+
+ catched = false;
+ try
+ {
+ l01.merge(l02);
+ }
+ catch(std::runtime_error&)
+ {
+ catched = true;
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ VERIFY( catched );
+ VERIFY( l01 == l01_ref );
+ VERIFY( l02 == l02_ref );
+
+ catched = false;
+ try
+ {
+ l01.merge(l02, std::less<int>());
+ }
+ catch(std::runtime_error&)
+ {
+ catched = true;
+ }
+ catch(...)
+ {
+ VERIFY( false );
+ }
+ VERIFY( catched );
+ VERIFY( l01 == l01_ref );
+ VERIFY( l02 == l02_ref );
+}
diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
index 9818c5ca1dd..6c4200eeffb 100644
--- a/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/minmax/2.cc
@@ -27,25 +27,25 @@ void test01()
{
bool test __attribute__((unused)) = true;
- std::pair<const int&, const int&> z = std::minmax({1, 2, 3});
- std::pair<const int&, const int&> w = std::minmax({4, 3, 5, 4});
- std::pair<const int&, const int&> y = std::minmax({4, 5, 3, 7, 3});
+ std::pair<int, int> z = std::minmax({1, 2, 3});
+ std::pair<int, int> w = std::minmax({4, 3, 5, 4});
+ std::pair<int, int> 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<const int&, const int&> zc =
+
+ std::pair<int, int> zc =
std::minmax({1, 2, 3}, std::greater<int>());
-
- std::pair<const int&, const int&> wc =
+
+ std::pair<int, int> wc =
std::minmax({4, 3, 5, 4}, std::greater<int>());
-
- std::pair<const int&, const int&> yc =
+
+ std::pair<int, int> yc =
std::minmax({4, 5, 3, 7, 3}, std::greater<int>());
-
+
VERIFY( zc.first == 3 );
VERIFY( zc.second == 1 );
VERIFY( wc.first == 5 );
diff --git a/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc b/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
index 5e896e208f7..f0944b0bfde 100644
--- a/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/minmax/3.cc
@@ -41,8 +41,8 @@ void test01()
{
bool test __attribute__((unused)) = true;
- std::pair<const int&, const int&> z = std::minmax({1, 2, 3, 4, 5, 6, 7, 8},
- compare_counter());
+ std::pair<int, int> z = 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.
diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc
index c1bfc04b0e1..0e83565e0de 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc
@@ -23,6 +23,7 @@
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
+#include <limits>
#include <testsuite_hooks.h>
void
@@ -32,9 +33,9 @@ test01()
std::uniform_int_distribution<int> u;
VERIFY( u.a() == 0 );
- VERIFY( u.b() == 9 );
+ VERIFY( u.b() == std::numeric_limits<int>::max() );
VERIFY( u.min() == 0 );
- VERIFY( u.max() == 9 );
+ VERIFY( u.max() == std::numeric_limits<int>::max() );
}
int main()
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
index e580d807585..0b73b080fbe 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc
@@ -29,7 +29,7 @@ int main()
return 0;
}
-// { dg-error "used here" "" { target *-*-* } 521 }
+// { dg-error "used here" "" { target *-*-* } 525 }
// { dg-error "deleted function" "" { target *-*-* } 239 }
// { dg-error "deleted function" "" { target *-*-* } 257 }
// { dg-error "deleted function" "" { target *-*-* } 275 }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
index 9108b4bc1ac..a261a84c968 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc
@@ -29,7 +29,7 @@ int main()
return 0;
}
-// { dg-error "used here" "" { target *-*-* } 560 }
+// { dg-error "used here" "" { target *-*-* } 564 }
// { dg-error "deleted function" "" { target *-*-* } 238 }
// { dg-error "deleted function" "" { target *-*-* } 256 }
// { dg-error "deleted function" "" { target *-*-* } 274 }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
index cf69ab2ee56..a488cb06d14 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc
@@ -30,11 +30,11 @@ int main()
return 0;
}
-// { dg-error "used here" "" { target *-*-* } 521 }
+// { dg-error "used here" "" { target *-*-* } 525 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 29 }
-// { dg-error "instantiated from" "" { target *-*-* } 528 }
+// { dg-error "instantiated from" "" { target *-*-* } 532 }
// { dg-error "instantiated from" "" { target *-*-* } 170 }
// { dg-error "instantiated from" "" { target *-*-* } 399 }
// { dg-error "instantiated from" "" { target *-*-* } 168 }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
index 369cba826f4..71eb282fcd8 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc
@@ -30,11 +30,11 @@ int main()
return 0;
}
-// { dg-error "used here" "" { target *-*-* } 560 }
+// { dg-error "used here" "" { target *-*-* } 564 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 29 }
-// { dg-error "instantiated from" "" { target *-*-* } 566 }
+// { dg-error "instantiated from" "" { target *-*-* } 570 }
// { dg-error "instantiated from" "" { target *-*-* } 170 }
// { dg-error "instantiated from" "" { target *-*-* } 399 }
// { dg-error "instantiated from" "" { target *-*-* } 168 }
diff --git a/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc b/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc
new file mode 100644
index 00000000000..5f021b8e5ac
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/headers/future/std_c++0x_neg.cc
@@ -0,0 +1,26 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++98" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+#include <future> // { dg-excess-errors "In file included from" }
+
+// { dg-error "upcoming ISO" "" { target *-*-* } 31 }
+
+
+
diff --git a/libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc b/libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc
new file mode 100644
index 00000000000..16a54b4147a
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/headers/future/types_std_c++0x.cc
@@ -0,0 +1,49 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+#include <future>
+
+void test01()
+{
+ typedef std::future_errc errc_t;
+
+ using std::future_category;
+
+ typedef std::future_error error_t;
+
+ typedef std::unique_future<int> uniq_t;
+ typedef std::unique_future<int&> uniqr_t;
+ typedef std::unique_future<void> uniqv_t;
+
+ typedef std::shared_future<int> shar_t;
+ typedef std::shared_future<int&> sharr_t;
+ typedef std::shared_future<void> sharv_t;
+
+ typedef std::promise<int> promise_t;
+ typedef std::promise<int&> promiser_t;
+ typedef std::promise<void> promisev_t;
+
+ typedef std::packaged_task<int> ptask_t;
+ typedef std::packaged_task<int&> ptaskr_t;
+ typedef std::packaged_task<void> ptaskv_t;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc
new file mode 100644
index 00000000000..a2414333e22
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/1.cc
@@ -0,0 +1,53 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::packaged_task;
+ using namespace __gnu_test;
+
+ packaged_task<int ()> p1;
+ VERIFY( !static_cast<bool>(p1) );
+ packaged_task<int& ()> p2;
+ VERIFY( !static_cast<bool>(p2) );
+ packaged_task<void ()> p3;
+ VERIFY( !static_cast<bool>(p3) );
+ packaged_task<ClassType ()> p4;
+ VERIFY( !static_cast<bool>(p4) );
+ packaged_task<AbstractClass& (int)> p5;
+ VERIFY( !static_cast<bool>(p5) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc
new file mode 100644
index 00000000000..98f5de73c4d
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/2.cc
@@ -0,0 +1,64 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+
+int f1() { return 0; }
+int& f2() { static int i; return i; }
+void f3() { }
+ClassType f4() { return ClassType(); }
+
+struct Derived : AbstractClass {
+ void rotate(int) { }
+ Derived& operator()(int i) { rotate(i); return *this; }
+} f5;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::packaged_task;
+
+ packaged_task<int ()> p1(f1);
+ VERIFY( static_cast<bool>(p1) );
+ packaged_task<int& ()> p2(f2);
+ VERIFY( static_cast<bool>(p2) );
+ packaged_task<void ()> p3(f3);
+ VERIFY( static_cast<bool>(p3) );
+ packaged_task<ClassType ()> p4(f4);
+ VERIFY( static_cast<bool>(p4) );
+ packaged_task<AbstractClass& (int)> p5(f5);
+ VERIFY( static_cast<bool>(p5) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc
new file mode 100644
index 00000000000..5f02dea0156
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/assign_neg.cc
@@ -0,0 +1,36 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+void test01()
+{
+ // assign
+ std::packaged_task<int()> p1;
+ std::packaged_task<int()> p2;
+ p1 = p2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 32 }
+// { dg-error "deleted function" "" { target *-*-* } 856 }
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc
new file mode 100644
index 00000000000..6a50d7802aa
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/copy_neg.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+void test01()
+{
+ // copy
+ std::packaged_task<int()> p1;
+ std::packaged_task<int()> p2(p1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 31 }
+// { dg-error "deleted function" "" { target *-*-* } 855 }
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc
new file mode 100644
index 00000000000..5335db39949
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move.cc
@@ -0,0 +1,49 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int f1() { return 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ // move
+ packaged_task<int()> p1(f1);
+ packaged_task<int()> p2(std::move(p1));
+ VERIFY( !static_cast<bool>(p1) );
+ VERIFY( static_cast<bool>(p2) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc
new file mode 100644
index 00000000000..c23e5e3b72b
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/move_assign.cc
@@ -0,0 +1,49 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int gen() { return 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ // move assign
+ std::packaged_task<int()> p1;
+ std::packaged_task<int()> p2(gen);
+ p1 = std::move(p2);
+ VERIFY( static_cast<bool>(p1) );
+ VERIFY( !static_cast<bool>(p2) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc
new file mode 100644
index 00000000000..c332b85741d
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/boolconv.cc
@@ -0,0 +1,47 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<int()> p1;
+ VERIFY( !static_cast<bool>(p1) );
+
+ std::packaged_task<int()> p2(zero);
+ VERIFY( static_cast<bool>(p2) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc
new file mode 100644
index 00000000000..c1bc129e26f
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future.cc
@@ -0,0 +1,55 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int& inc(int& i) { return ++i; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<int&(int&)> p1(inc);
+ std::unique_future<int&> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ int i1 = 0;
+
+ p1(i1);
+
+ int& i2 = f1.get();
+
+ VERIFY( &i1 == &i2 );
+ VERIFY( i1 == 1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc
new file mode 100644
index 00000000000..a6c9c61e5c8
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/get_future2.cc
@@ -0,0 +1,57 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int& inc(int& i) { return ++i; }
+
+void test01()
+{
+ bool test = false;
+
+ std::packaged_task<int&(int&)> p1(inc);
+ p1.get_future();
+
+ try
+ {
+ p1.get_future();
+ VERIFY( false );
+ }
+ catch (std::bad_function_call&)
+ {
+ test = true;
+ }
+
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc
new file mode 100644
index 00000000000..2797b0606bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke.cc
@@ -0,0 +1,49 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<int()> p1(zero);
+ std::unique_future<int> f1 = p1.get_future();
+
+ p1();
+
+ VERIFY( static_cast<bool>(p1) );
+ VERIFY( f1.has_value() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc
new file mode 100644
index 00000000000..fae15dcac65
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke2.cc
@@ -0,0 +1,56 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+bool odd(unsigned i) { return i%2; }
+
+void test01()
+{
+ bool test = false;
+
+ std::packaged_task<bool(unsigned)> p1(odd);
+
+ p1(5);
+
+ try
+ {
+ p1(4);
+ }
+ catch (std::bad_function_call&)
+ {
+ test = true;
+ }
+
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc
new file mode 100644
index 00000000000..91d43413d35
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke3.cc
@@ -0,0 +1,60 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int& inc(int& i) { ++i; return i; }
+
+void test01()
+{
+ bool test = false;
+
+ std::packaged_task<void(int&)> p1(inc);
+
+ int i1 = 0;
+ p1(i1);
+
+ VERIFY( i1 == 1 );
+
+ try
+ {
+ p1(i1);
+ }
+ catch (std::bad_function_call&)
+ {
+ test = true;
+ }
+
+ VERIFY( i1 == 1 );
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc
new file mode 100644
index 00000000000..eefb313b7a4
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke4.cc
@@ -0,0 +1,48 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void thrower() { throw 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<void()> p1(thrower);
+ std::unique_future<void> f1 = p1.get_future();
+
+ p1();
+
+ VERIFY( f1.has_exception() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc
new file mode 100644
index 00000000000..925dc108fe9
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/invoke5.cc
@@ -0,0 +1,51 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <thread>
+#include <testsuite_hooks.h>
+
+void noop() { }
+void waiter(std::shared_future<void> f) { f.wait(); }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<void()> p1(noop);
+ std::shared_future<void> f1(p1.get_future());
+ std::thread t1(waiter, f1);
+
+ p1();
+
+ t1.join();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc
new file mode 100644
index 00000000000..66b9f3da669
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset.cc
@@ -0,0 +1,65 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+void test01()
+{
+ bool test = false;
+ using namespace std;
+
+ packaged_task<int()> p1(zero);
+ unique_future<int> f1 = p1.get_future();
+
+ p1.reset();
+ VERIFY( static_cast<bool>(p1) );
+
+ unique_future<int> f2 = p1.get_future();
+ VERIFY( !f2.is_ready() );
+
+ VERIFY( f1.has_exception() );
+ try
+ {
+ f1.get();
+ }
+ catch (future_error& e)
+ {
+ VERIFY( e.code() == make_error_code(future_errc::broken_promise) );
+ test = true;
+ }
+
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc
new file mode 100644
index 00000000000..69ee9a99213
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/reset2.cc
@@ -0,0 +1,53 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<int()> p1(zero);
+ std::unique_future<int> f1 = p1.get_future();
+
+ p1();
+ p1.reset();
+
+ VERIFY( static_cast<bool>(p1) );
+ VERIFY( f1.has_value() );
+
+ std::unique_future<int> f2 = p1.get_future();
+ VERIFY( !f2.is_ready() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc
new file mode 100644
index 00000000000..ced2a00529a
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/members/swap.cc
@@ -0,0 +1,49 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::packaged_task<int()> p1(zero);
+ std::packaged_task<int()> p2;
+ VERIFY( static_cast<bool>(p1) );
+ VERIFY( !static_cast<bool>(p2) );
+ p1.swap(p2);
+ VERIFY( !static_cast<bool>(p1) );
+ VERIFY( static_cast<bool>(p2) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc
new file mode 100644
index 00000000000..4d55603c83e
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+using std::packaged_task;
+template class packaged_task<int()>;
+template class packaged_task<int&()>;
+template class packaged_task<void()>;
+template class packaged_task<ClassType(int)>;
+template class packaged_task<AbstractClass&(int)>;
diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc
new file mode 100644
index 00000000000..79120b7cd2b
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/cons/1.cc
@@ -0,0 +1,46 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ using std::promise;
+ using namespace __gnu_test;
+
+ promise<int> p1;
+ promise<int&> p2;
+ promise<void> p3;
+ promise<ClassType> p4;
+ promise<AbstractClass&> p5;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc
new file mode 100644
index 00000000000..cebe5f981d8
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/cons/assign_neg.cc
@@ -0,0 +1,36 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+void test01()
+{
+ // assign
+ std::promise<int> p1;
+ std::promise<int> p2;
+ p1 = p2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 32 }
+// { dg-error "deleted function" "" { target *-*-* } 582 }
diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc
new file mode 100644
index 00000000000..cbcdcfb6d25
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/cons/copy_neg.cc
@@ -0,0 +1,35 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+void test01()
+{
+ // copy
+ std::promise<int> p1;
+ std::promise<int> p2(p1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 31 }
+// { dg-error "deleted function" "" { target *-*-* } 566 }
diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc
new file mode 100644
index 00000000000..8b1e1399801
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/cons/move.cc
@@ -0,0 +1,55 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ // move assign
+ promise<int> p1;
+ p1.set_value(3);
+ promise<int> p2(std::move(p1));
+ VERIFY( p2.get_future().get() == 3 );
+ try
+ {
+ p1.get_future();
+ VERIFY( false );
+ }
+ catch (std::future_error& e)
+ {
+ VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved));
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc b/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc
new file mode 100644
index 00000000000..c5bda4d3560
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/cons/move_assign.cc
@@ -0,0 +1,56 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std;
+
+ // move assign
+ promise<int> p1;
+ p1.set_value(3);
+ promise<int> p2;
+ p2 = move(p1);
+ VERIFY( p2.get_future().get() == 3 );
+ try
+ {
+ p1.get_future();
+ VERIFY( false );
+ }
+ catch (future_error& e)
+ {
+ VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved));
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc b/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc
new file mode 100644
index 00000000000..7e969908a99
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/get_future.cc
@@ -0,0 +1,52 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int&> p1;
+ std::unique_future<int&> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ int i1 = 0;
+
+ p1.set_value(i1);
+
+ int& i2 = f1.get();
+
+ VERIFY( &i1 == &i2 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc
new file mode 100644
index 00000000000..cc44fc47919
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/get_future2.cc
@@ -0,0 +1,57 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test = false;
+ using namespace std;
+
+ promise<int&> p1;
+ p1.get_future();
+
+ try
+ {
+ p1.get_future();
+ VERIFY( false );
+ }
+ catch (future_error& e)
+ {
+ VERIFY(e.code() == make_error_code(future_errc::future_already_retrieved));
+ test = true;
+ }
+
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc
new file mode 100644
index 00000000000..e5b8f60aa3a
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception.cc
@@ -0,0 +1,49 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ p1.set_exception(std::copy_exception(0));
+
+ VERIFY( f1.has_exception() );
+ VERIFY( !f1.has_value() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc
new file mode 100644
index 00000000000..3bbe28d48da
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_exception2.cc
@@ -0,0 +1,95 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test = false;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1 = p1.get_future();
+
+ p1.set_exception(std::copy_exception(0));
+
+ try
+ {
+ p1.set_exception(std::copy_exception(1));
+ VERIFY( false );
+ }
+ catch (std::future_error& e)
+ {
+ VERIFY(e.code() ==
+ std::make_error_code(std::future_errc::promise_already_satisfied));
+ test = true;
+ }
+
+ try
+ {
+ f1.get();
+ test = false;
+ }
+ catch(int i)
+ {
+ VERIFY( i == 0 );
+ }
+
+ VERIFY( test );
+}
+
+void test02()
+{
+ bool test = false;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1 = p1.get_future();
+
+ p1.set_value(2);
+
+ try
+ {
+ p1.set_exception(std::copy_exception(0));
+ VERIFY( false );
+ }
+ catch (std::future_error& e)
+ {
+ VERIFY(e.code() ==
+ std::make_error_code(std::future_errc::promise_already_satisfied));
+ test = true;
+ }
+
+ VERIFY( f1.has_value() );
+ VERIFY( !f1.has_exception() );
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc
new file mode 100644
index 00000000000..978ef1914b0
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value.cc
@@ -0,0 +1,105 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+#include <testsuite_rvalref.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ p1.set_value(0);
+
+ int&& i1 = f1.get();
+
+ VERIFY( i1 == 0 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ using __gnu_test::rvalstruct;
+
+ std::promise<rvalstruct> p1;
+ std::unique_future<rvalstruct> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ p1.set_value(rvalstruct(1));
+
+ rvalstruct r1(f1.get());
+
+ VERIFY( r1.valid );
+ VERIFY( r1.val == 1 );
+}
+
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int&> p1;
+ std::unique_future<int&> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ int i1 = 0;
+ p1.set_value(i1);
+ int& i2 = f1.get();
+
+ VERIFY( &i1 == &i2 );
+}
+
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<void> p1;
+ std::unique_future<void> f1 = p1.get_future();
+
+ VERIFY( !f1.is_ready() );
+
+ p1.set_value();
+ f1.get();
+
+ VERIFY( f1.is_ready() );
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+ test04();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc
new file mode 100644
index 00000000000..58e2fe813e4
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value2.cc
@@ -0,0 +1,88 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test = false;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1 = p1.get_future();
+
+ p1.set_value(1);
+
+ try
+ {
+ p1.set_value(2);
+ VERIFY( false );
+ }
+ catch (std::future_error& e)
+ {
+ VERIFY(e.code() ==
+ std::make_error_code(std::future_errc::promise_already_satisfied));
+ test = true;
+ }
+
+ VERIFY( f1.has_value() );
+ VERIFY( f1.get() == 1 );
+ VERIFY( test );
+}
+
+void test02()
+{
+ bool test = false;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1 = p1.get_future();
+
+ p1.set_value(3);
+
+ try
+ {
+ p1.set_exception(std::copy_exception(4));
+ VERIFY( false );
+ }
+ catch (std::future_error& e)
+ {
+ VERIFY(e.code() ==
+ std::make_error_code(std::future_errc::promise_already_satisfied));
+ test = true;
+ }
+
+ VERIFY( f1.has_value() );
+ VERIFY( !f1.has_exception() );
+ VERIFY( f1.get() == 3 );
+ VERIFY( test );
+}
+
+int main()
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc b/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc
new file mode 100644
index 00000000000..92581964e3c
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/set_value3.cc
@@ -0,0 +1,87 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+
+// Test promise::set_value() for deadlock by checking if the state is ready
+// during construction and destruction of the associated state.
+
+struct tester
+{
+ tester(int);
+ tester(const tester&);
+ tester() = delete;
+ ~tester();
+ tester& operator=(const tester&);
+};
+
+std::promise<tester> pglobal;
+std::unique_future<tester> fglobal = pglobal.get_future();
+
+tester::tester(int)
+{
+ bool test __attribute__((unused)) = true;
+ VERIFY (!fglobal.is_ready());
+}
+
+tester::tester(const tester&)
+{
+ bool test __attribute__((unused)) = true;
+ // if this copy happens while a mutex is locked next line could deadlock:
+ VERIFY (!fglobal.is_ready());
+}
+
+tester& tester::operator=(const tester&)
+{
+ bool test __attribute__((unused)) = true;
+ // if this copy happens while a mutex is locked next line could deadlock:
+ VERIFY (!fglobal.is_ready());
+ return *this;
+}
+
+tester::~tester()
+{
+ bool test __attribute__((unused)) = true;
+ VERIFY (fglobal.is_ready());
+}
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ pglobal.set_value( tester(1) );
+
+ VERIFY( fglobal.is_ready() );
+}
+
+int main()
+{
+ test01();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc b/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc
new file mode 100644
index 00000000000..8bfbdfd6c8f
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/members/swap.cc
@@ -0,0 +1,46 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::promise<int> p2;
+ p1.set_value(1);
+ p1.swap(p2);
+ VERIFY( !p1.get_future().is_ready() );
+ VERIFY( p2.get_future().is_ready() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc
new file mode 100644
index 00000000000..903b3ab146e
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/promise/requirements/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+using std::promise;
+template class promise<int>;
+template class promise<int&>;
+template class promise<void>;
+template class promise<ClassType>;
+template class promise<ClassType&>;
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc
new file mode 100644
index 00000000000..3b446d06de5
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/assign_neg.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+extern std::shared_future<int>& get();
+
+void test01()
+{
+ // assign
+ std::shared_future<int>& p1 = get();
+ std::shared_future<int>& p2 = get();
+ p1 = p2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 34 }
+// { dg-error "deleted function" "" { target *-*-* } 475 }
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc
new file mode 100644
index 00000000000..16954a1d4c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/copy.cc
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+extern std::unique_future<int>& get();
+
+void test01()
+{
+ using std::shared_future;
+
+ shared_future<int> p1 = get();
+ shared_future<int> p2(p1);
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/default_neg.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/default_neg.cc
new file mode 100644
index 00000000000..cc4aadfce6f
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/default_neg.cc
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ using std::shared_future;
+ using namespace __gnu_test;
+
+ shared_future<int> p1; // { dg-error "22: error: no match" }
+ shared_future<int&> p2; // { dg-error "23: error: no match" }
+ shared_future<void> p3; // { dg-error "23: error: no match" }
+ shared_future<ClassType> p4; // { dg-error "28: error: no match" }
+ shared_future<AbstractClass&> p5; // { dg-error "33: error: no match" }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "note" }
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc b/libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc
new file mode 100644
index 00000000000..3494a10463f
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/cons/move.cc
@@ -0,0 +1,41 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+void test01()
+{
+ // construct from rvalue unique_future
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(std::move(f1));
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc
new file mode 100644
index 00000000000..bf773c31d52
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc
@@ -0,0 +1,78 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int value = 99;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ p1.set_value(value);
+ VERIFY( f1.get() == value );
+ VERIFY( f2.get() == value );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int&> p1;
+ std::shared_future<int&> f1(p1.get_future());
+ std::shared_future<int&> f2(f1);
+
+ p1.set_value(value);
+ VERIFY( &f1.get() == &value );
+ VERIFY( &f2.get() == &value );
+}
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<void> p1;
+ std::shared_future<void> f1(p1.get_future());
+ std::shared_future<void> f2(f1);
+
+ p1.set_value();
+ f1.get();
+ f2.get();
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc
new file mode 100644
index 00000000000..80dd368a973
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/get2.cc
@@ -0,0 +1,127 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <exception>
+#include <testsuite_hooks.h>
+
+int value = 99;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ p1.set_exception(std::copy_exception(value));
+ try
+ {
+ (void) f1.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+ try
+ {
+ (void) f2.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int&> p1;
+ std::shared_future<int&> f1(p1.get_future());
+ std::shared_future<int&> f2(f1);
+
+ p1.set_exception(std::copy_exception(value));
+ try
+ {
+ (void) f1.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+ try
+ {
+ (void) f2.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+}
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<void> p1;
+ std::shared_future<void> f1(p1.get_future());
+ std::shared_future<void> f2(f1);
+
+ p1.set_exception(std::copy_exception(value));
+ try
+ {
+ f1.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+ try
+ {
+ f2.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/has_exception.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/has_exception.cc
new file mode 100644
index 00000000000..97d398025e5
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/has_exception.cc
@@ -0,0 +1,70 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ VERIFY( !f1.has_exception() );
+ VERIFY( !f2.has_exception() );
+
+ p1.set_exception(std::copy_exception(1));
+
+ VERIFY( f1.has_exception() );
+ VERIFY( f2.has_exception() );
+}
+
+void test02()
+{
+ std::promise<int> p1;
+ bool test __attribute__((unused)) = true;
+
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ VERIFY( !f1.has_exception() );
+ VERIFY( !f2.has_exception() );
+
+ p1.set_value(1);
+
+ VERIFY( !f1.has_exception() );
+ VERIFY( !f2.has_exception() );
+}
+
+int main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/has_value.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/has_value.cc
new file mode 100644
index 00000000000..8903c825f88
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/has_value.cc
@@ -0,0 +1,70 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ VERIFY( !f1.has_value() );
+ VERIFY( !f2.has_value() );
+
+ p1.set_value(1);
+
+ VERIFY( f1.has_value() );
+ VERIFY( f2.has_value() );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ VERIFY( !f1.has_value() );
+ VERIFY( !f2.has_value() );
+
+ p1.set_exception(std::copy_exception(1));
+
+ VERIFY( !f1.has_value() );
+ VERIFY( !f2.has_value() );
+}
+
+int main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/is_ready.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/is_ready.cc
new file mode 100644
index 00000000000..eb2252a664b
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/is_ready.cc
@@ -0,0 +1,51 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ VERIFY( !f1.is_ready() );
+ VERIFY( !f2.is_ready() );
+
+ p1.set_value(1);
+
+ VERIFY( f1.is_ready() );
+ VERIFY( f2.is_ready() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc
new file mode 100644
index 00000000000..a4e325b0d96
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/wait.cc
@@ -0,0 +1,56 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <thread>
+#include <mutex>
+#include <testsuite_hooks.h>
+
+void wait(std::shared_future<void> f)
+{
+ f.wait();
+}
+
+void test01()
+{
+ std::promise<void> p1;
+ std::shared_future<void> f1(p1.get_future());
+
+ std::thread t1(wait, f1);
+ std::thread t2(wait, f1);
+ std::thread t3(wait, f1);
+
+ p1.set_value();
+ t1.join();
+ t2.join();
+ t3.join();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc
new file mode 100644
index 00000000000..408b6460225
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_for.cc
@@ -0,0 +1,56 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <chrono>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ std::chrono::milliseconds delay(100);
+
+ VERIFY( !f1.wait_for(delay) );
+ VERIFY( !f2.wait_for(delay) );
+
+ p1.set_value(1);
+
+ auto before = std::chrono::system_clock::now();
+ VERIFY( f1.wait_for(delay) );
+ VERIFY( f2.wait_for(delay) );
+ VERIFY( std::chrono::system_clock::now() < (before + 2*delay) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc b/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc
new file mode 100644
index 00000000000..561fb20952d
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/wait_until.cc
@@ -0,0 +1,64 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <chrono>
+#include <testsuite_hooks.h>
+
+std::chrono::system_clock::time_point make_time(int i)
+{
+ return std::chrono::system_clock::now() + std::chrono::milliseconds(i);
+}
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::shared_future<int> f1(p1.get_future());
+ std::shared_future<int> f2(f1);
+
+ auto when = make_time(10);
+ VERIFY( !f1.wait_until(make_time(10)) );
+ VERIFY( std::chrono::system_clock::now() >= when );
+
+ when = make_time(10);
+ VERIFY( !f2.wait_until(make_time(10)) );
+ VERIFY( std::chrono::system_clock::now() >= when );
+
+ p1.set_value(1);
+
+ when = make_time(100);
+ VERIFY( f1.wait_until(when) );
+ VERIFY( f2.wait_until(when) );
+ VERIFY( std::chrono::system_clock::now() < when );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc
new file mode 100644
index 00000000000..4c1b3b276bd
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+using std::shared_future;
+template class shared_future<int>;
+template class shared_future<int&>;
+template class shared_future<void>;
+template class shared_future<ClassType>;
+template class shared_future<ClassType&>;
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc b/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc
new file mode 100644
index 00000000000..928ee0a48e9
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/cons/assign_neg.cc
@@ -0,0 +1,38 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+extern std::unique_future<int>& get();
+
+void test01()
+{
+ // assign
+ std::unique_future<int>& p1 = get();
+ std::unique_future<int>& p2 = get();
+ p1 = p2;
+}
+
+// { dg-error "used here" "" { target *-*-* } 34 }
+// { dg-error "deleted function" "" { target *-*-* } 395 }
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc
new file mode 100644
index 00000000000..5153636e9ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/cons/copy_neg.cc
@@ -0,0 +1,37 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+extern std::unique_future<int>& get();
+
+void test01()
+{
+ // copy
+ std::unique_future<int>& p1 = get();
+ std::unique_future<int> p2(p1);
+}
+
+// { dg-error "used here" "" { target *-*-* } 33 }
+// { dg-error "deleted function" "" { target *-*-* } 394 }
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/cons/default_neg.cc b/libstdc++-v3/testsuite/30_threads/unique_future/cons/default_neg.cc
new file mode 100644
index 00000000000..ba5066bfcab
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/cons/default_neg.cc
@@ -0,0 +1,45 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ using std::unique_future;
+ using namespace __gnu_test;
+
+ unique_future<int> p1; // { dg-error "22: error: no match" }
+ unique_future<int&> p2; // { dg-error "23: error: no match" }
+ unique_future<void> p3; // { dg-error "23: error: no match" }
+ unique_future<ClassType> p4; // { dg-error "28: error: no match" }
+ unique_future<AbstractClass&> p5; // { dg-error "33: error: no match" }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
+// { dg-excess-errors "note" }
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/cons/move.cc b/libstdc++-v3/testsuite/30_threads/unique_future/cons/move.cc
new file mode 100644
index 00000000000..17eaa914e4e
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/cons/move.cc
@@ -0,0 +1,41 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+
+void test01()
+{
+ // move
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+ std::unique_future<int> f2(std::move(f1));
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/get.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/get.cc
new file mode 100644
index 00000000000..5c9a4548491
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/get.cc
@@ -0,0 +1,70 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+int value = 99;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ p1.set_value(value);
+ VERIFY( f1.get() == value );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int&> p1;
+ std::unique_future<int&> f1(p1.get_future());
+
+ p1.set_value(value);
+ VERIFY( &f1.get() == &value );
+}
+
+void test03()
+{
+ std::promise<void> p1;
+ std::unique_future<void> f1(p1.get_future());
+
+ p1.set_value();
+ f1.get();
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/get2.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/get2.cc
new file mode 100644
index 00000000000..e6317fed838
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/get2.cc
@@ -0,0 +1,97 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <exception>
+#include <testsuite_hooks.h>
+
+int value = 99;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ p1.set_exception(std::copy_exception(value));
+ try
+ {
+ (void) f1.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int&> p1;
+ std::unique_future<int&> f1(p1.get_future());
+
+ p1.set_exception(std::copy_exception(value));
+ try
+ {
+ (void) f1.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+}
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<void> p1;
+ std::unique_future<void> f1(p1.get_future());
+
+ p1.set_exception(std::copy_exception(value));
+ try
+ {
+ f1.get();
+ VERIFY( false );
+ }
+ catch (int& e)
+ {
+ VERIFY( e == value );
+ }
+}
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/has_exception.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/has_exception.cc
new file mode 100644
index 00000000000..1d5baf88393
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/has_exception.cc
@@ -0,0 +1,64 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ VERIFY( !f1.has_exception() );
+
+ p1.set_exception(std::copy_exception(1));
+
+ VERIFY( f1.has_exception() );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ VERIFY( !f1.has_exception() );
+
+ p1.set_value(1);
+
+ VERIFY( !f1.has_exception() );
+}
+
+int main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/has_value.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/has_value.cc
new file mode 100644
index 00000000000..f1f96f21ddc
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/has_value.cc
@@ -0,0 +1,65 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ VERIFY( !f1.has_value() );
+
+ p1.set_value(1);
+
+ VERIFY( f1.has_value() );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ VERIFY( !f1.has_value() );
+
+ p1.set_exception(std::copy_exception(1));
+
+ VERIFY( !f1.has_value() );
+}
+
+int main()
+{
+ test01();
+ test02();
+
+ return 0;
+}
+
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/is_ready.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/is_ready.cc
new file mode 100644
index 00000000000..6f2b6885595
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/is_ready.cc
@@ -0,0 +1,48 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ VERIFY( !f1.is_ready() );
+
+ p1.set_value(1);
+
+ VERIFY( f1.is_ready() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/wait.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/wait.cc
new file mode 100644
index 00000000000..b9c9402cf31
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/wait.cc
@@ -0,0 +1,54 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <chrono>
+#include <thread>
+#include <mutex>
+#include <testsuite_hooks.h>
+
+
+void wait(std::unique_future<void>& f)
+{
+ f.wait();
+}
+
+void test01()
+{
+ std::promise<void> p1;
+ std::unique_future<void> f1(p1.get_future());
+
+ std::thread t1(wait, std::ref(f1));
+
+ p1.set_value();
+ t1.join();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/wait_for.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/wait_for.cc
new file mode 100644
index 00000000000..065240097b1
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/wait_for.cc
@@ -0,0 +1,53 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <chrono>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ std::chrono::milliseconds delay(100);
+
+ VERIFY( !f1.wait_for(delay) );
+
+ p1.set_value(1);
+
+ auto before = std::chrono::system_clock::now();
+ VERIFY( f1.wait_for(delay) );
+ VERIFY( std::chrono::system_clock::now() < (before + delay) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/members/wait_until.cc b/libstdc++-v3/testsuite/30_threads/unique_future/members/wait_until.cc
new file mode 100644
index 00000000000..55bdcbcc76c
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/members/wait_until.cc
@@ -0,0 +1,58 @@
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } }
+// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <chrono>
+#include <testsuite_hooks.h>
+
+std::chrono::system_clock::time_point make_time(int i)
+{
+ return std::chrono::system_clock::now() + std::chrono::milliseconds(i);
+}
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::promise<int> p1;
+ std::unique_future<int> f1(p1.get_future());
+
+ auto when = make_time(10);
+ VERIFY( !f1.wait_until(when) );
+ VERIFY( std::chrono::system_clock::now() >= when );
+
+ p1.set_value(1);
+
+ when = make_time(100);
+ VERIFY( f1.wait_until(when) );
+ VERIFY( std::chrono::system_clock::now() < when );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc
new file mode 100644
index 00000000000..01e5c5924b2
--- /dev/null
+++ b/libstdc++-v3/testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc
@@ -0,0 +1,34 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+using std::unique_future;
+template class unique_future<int>;
+template class unique_future<int&>;
+template class unique_future<void>;
+template class unique_future<ClassType>;
+template class unique_future<ClassType&>;
diff --git a/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc b/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc
new file mode 100644
index 00000000000..21405e18ad4
--- /dev/null
+++ b/libstdc++-v3/testsuite/performance/30_threads/future/polling.cc
@@ -0,0 +1,55 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+
+
+#include <future>
+#include <thread>
+#include <testsuite_performance.h>
+
+void poll(std::shared_future<void> f)
+{
+ while (!f.is_ready())
+ { }
+}
+
+int main()
+{
+ using namespace __gnu_test;
+ time_counter time;
+ resource_counter resource;
+
+ const int n = 20;
+ std::promise<void> p;
+ std::shared_future<void> f = p.get_future();
+ std::thread pollers[n];
+ for (int i=0; i < n; ++i)
+ pollers[i] = std::thread(poll, f);
+
+ start_counters(time, resource);
+
+ for (int i = 0; i < 1000000; ++i)
+ (void)f.is_ready();
+ p.set_value();
+
+ for (int i=0; i < n; ++i)
+ pollers[i].join();
+
+ stop_counters(time, resource);
+ report_performance(__FILE__, "", time, resource);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h
index ba8a967feb3..c6c00689f3d 100644
--- a/libstdc++-v3/testsuite/util/testsuite_common_types.h
+++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h
@@ -387,8 +387,8 @@ namespace __gnu_test
void
bitwise_operators()
{
- _Tp a;
- _Tp b;
+ _Tp a = _Tp();
+ _Tp b = _Tp();
a | b;
a & b;
a ^ b;
@@ -399,8 +399,8 @@ namespace __gnu_test
void
bitwise_assignment_operators()
{
- _Tp a;
- _Tp b;
+ _Tp a = _Tp();
+ _Tp b = _Tp();
a |= b; // set
a &= ~b; // clear
a ^= b;
@@ -426,7 +426,11 @@ namespace __gnu_test
{
void __constraint()
{
- bitwise_assignment_operators<_Tp>();
+ _Tp a;
+ _Tp b;
+ a |= b; // set
+ a &= ~b; // clear
+ a ^= b;
}
};