This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[c++0x] <future>


Here is an implementation of <future>

This is as near as possible to the current working paper, n2857:
concepts, constexpr, new allocator support and explicit conversion
operators are missing.
There are some preprocessor conditions around missing features and g++
bugs, I'll remove them from the final version, this is really just to
let people try it out or comment, as I might be unable to work on it
again until next week.

The implementation is a pretty simple one using a mutex and condition
variable (smarter versions using atomics to eliminate some locking are
possible.) Most of the code that doesn't depend on the type of
future/promise is in _Future_state_base for the shared state, or in
_Future_impl for the per-instance state.  That was done to reduce the
amount of code instantiated for every template specialisation.

As I've implemented it, you'll get a segfault if you use almost any
member function on a future/promise after a std::move.  That's
intentional: the only requirement is that they can be safely
destroyed, so I didn't add any checks for empty shared_ptr.  I'm
thinking of adding some checking for debug mode (IMHO we should be
adding debug mode support to all new components where possible.)

The tests in this patch are a bit of a hodge-podge, some use
test01/test02 functions called by main, some have the test code
directly in main()... please let me know if I need to rework them.

I've also got some python pretty printers ready for futures and
promises, which I'll be able to add once Tom T. and Phil M. commit the
python stuff from project Archer (hint hint! ;-) so gdb will give you
useful info about the state such as "promise<int> (exception ready, 3
associated futures)" or "promise<Foo&> (not ready, no associated
futures)"

All comments very welcome,

Jonathan


        * include/std/future: New.
        * src/future.cc: New.
        * include/Makefile.am: Add.
        * include/Makefile.in: Regenerate.
        * src/Makefile.am: Add.
        * src/Makefile.in: Regenerate.
        * testsuite/30_threads/packaged_task/cons/assign_neg.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/copy_neg.cc: New.
        * testsuite/30_threads/packaged_task/cons/move.cc: New.
        * testsuite/30_threads/packaged_task/cons/move_assign.cc: New.
        * testsuite/30_threads/packaged_task/requirements/
        explicit_instantiation.cc: New.
        * testsuite/30_threads/packaged_task/members/invoke.cc: New.
        * testsuite/30_threads/packaged_task/members/get_future2.cc: New.
        * testsuite/30_threads/packaged_task/members/invoke2.cc: New.
        * testsuite/30_threads/packaged_task/members/boolconv.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/get_future.cc: New.
        * testsuite/30_threads/packaged_task/members/swap.cc: New.
        * testsuite/30_threads/promise/cons/assign_neg.cc: New.
        * testsuite/30_threads/promise/cons/1.cc: New.
        * testsuite/30_threads/promise/cons/copy_neg.cc: New.
        * testsuite/30_threads/promise/cons/move.cc: New.
        * testsuite/30_threads/promise/cons/move_assign.cc: New.
        * testsuite/30_threads/promise/requirements/
        explicit_instantiation.cc: New.
        * testsuite/30_threads/promise/members/get_future2.cc: New.
        * testsuite/30_threads/promise/members/set_value.cc: New.
        * testsuite/30_threads/promise/members/get_future.cc: New.
        * testsuite/30_threads/promise/members/set_exception.cc: New.
        * testsuite/30_threads/promise/members/swap.cc: New.
        * testsuite/30_threads/unique_future/cons/assign_neg.cc: New.
        * testsuite/30_threads/unique_future/cons/default_neg.cc: New.
        * testsuite/30_threads/unique_future/cons/copy_neg.cc: New.
        * testsuite/30_threads/unique_future/cons/move.cc: New.
        * testsuite/30_threads/unique_future/requirements/
        explicit_instantiation.cc: New.
        * testsuite/30_threads/unique_future/members/get.cc: New.
        * testsuite/30_threads/unique_future/members/is_ready.cc: New.
        * testsuite/30_threads/unique_future/members/wait_until.cc: New.
        * testsuite/30_threads/unique_future/members/get2.cc: New.
        * testsuite/30_threads/unique_future/members/wait.cc: New.
        * testsuite/30_threads/unique_future/members/has_value.cc: New.
        * testsuite/30_threads/unique_future/members/has_exception.cc: New.
        * testsuite/30_threads/unique_future/members/wait_for.cc: New.
        * testsuite/30_threads/shared_future/cons/assign_neg.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/cons/copy.cc: New.
        * testsuite/30_threads/shared_future/requirements/
        explicit_instantiation.cc: New.
        * testsuite/30_threads/shared_future/members/get.cc: New.
        * testsuite/30_threads/shared_future/members/is_ready.cc: New.
        * testsuite/30_threads/shared_future/members/wait_until.cc: New.
        * testsuite/30_threads/shared_future/members/get2.cc: New.
        * testsuite/30_threads/shared_future/members/wait.cc: New.
        * testsuite/30_threads/shared_future/members/has_value.cc: New.
        * testsuite/30_threads/shared_future/members/has_exception.cc: New.
        * testsuite/30_threads/shared_future/members/wait_for.cc: New.
Index: include/Makefile.am
===================================================================
--- include/Makefile.am	(revision 147496)
+++ include/Makefile.am	(working copy)
@@ -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 \
Index: include/Makefile.in
===================================================================
--- include/Makefile.in	(revision 147496)
+++ include/Makefile.in	(working copy)
@@ -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 \
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 147496)
+++ src/Makefile.am	(working copy)
@@ -190,6 +190,7 @@ sources = \
 	condition_variable.cc \
 	chrono.cc \
 	thread.cc \
+	future.cc \
 	${host_sources} \
 	${host_sources_extra} 
 
@@ -298,6 +299,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.
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 147496)
+++ src/Makefile.in	(working copy)
@@ -87,7 +87,7 @@ am__libstdc___la_SOURCES_DIST = atomic.c
 	ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
 	string-inst.cc throw_allocator.cc valarray-inst.cc \
 	wlocale-inst.cc wstring-inst.cc mutex.cc condition_variable.cc \
-	chrono.cc thread.cc atomicity.cc codecvt_members.cc \
+	chrono.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 \
@@ -114,7 +114,8 @@ am__objects_5 = atomic.lo bitmap_allocat
 	ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo \
 	string-inst.lo throw_allocator.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)
+	chrono.lo 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)
@@ -443,6 +444,7 @@ sources = \
 	condition_variable.cc \
 	chrono.cc \
 	thread.cc \
+	future.cc \
 	${host_sources} \
 	${host_sources_extra} 
 
@@ -910,6 +912,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
Index: include/std/future
===================================================================
--- include/std/future	(revision 0)
+++ include/std/future	(revision 0)
@@ -0,0 +1,880 @@
+// <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 <chrono>
+#include <functional>
+#include <memory>
+#include <mutex>
+#include <condition_variable>
+#include <system_error>
+#include <exception>
+
+#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 };
+
+#if 0
+  concept_map ErrorCodeEnum<future_errc> { }
+#else
+  template<>
+    struct is_error_code_enum<future_errc> : public true_type { };
+#endif
+
+  /// Points to a statically-allocated object derived from error_category.
+  extern const error_category* const future_category;
+
+#if 0
+  inline constexpr error_code make_error_code(future_errc e)
+  { return error_code(static_cast<int>(__errc), *future_category); }
+  inline constexpr error_condition make_error_condition(future_errc e)
+  { return error_condition(static_cast<int>(__errc), *future_category); }
+#else
+  _GLIBCXX_CONST error_code make_error_code(future_errc);
+  _GLIBCXX_CONST error_condition make_error_condition(future_errc);
+
+  inline error_code make_error_code(future_errc __errc)
+  { return error_code(static_cast<int>(__errc), *future_category); }
+
+  inline error_condition make_error_condition(future_errc __errc)
+  { return error_condition(static_cast<int>(__errc), *future_category); }
+#endif
+
+  /// Exception type thrown by futures.
+  class future_error : public std::logic_error
+  {
+  public:
+    explicit future_error(future_errc __ec)
+    : std::logic_error(""), _M_code(make_error_code(__ec))
+    { }
+
+    const error_code& code() const throw() { return _M_code; }
+
+    const char* what() const throw() { return "std::future_error"; }
+
+  private:
+    error_code _M_code;
+  };
+
+  // common base class used by all specializations of _Future_state<R>
+  class _Future_state_base
+  {
+    std::condition_variable     _M_cond;
+    std::exception_ptr          _M_error;
+    bool                        _M_ready;
+    bool                        _M_retrieved;
+
+  public:
+    _Future_state_base() : _M_ready(false), _M_retrieved(false) { }
+
+    std::mutex                  _M_mutex;
+
+    bool
+    is_ready()
+    {
+      std::lock_guard<std::mutex> __lock(_M_mutex);
+      return _M_ready;
+    }
+
+    bool
+    has_exception()
+    {
+      std::lock_guard<std::mutex> __lock(_M_mutex);
+      return _M_ready && _M_error;
+    }
+
+    bool
+    has_value()
+    {
+      std::lock_guard<std::mutex> __lock(_M_mutex);
+      return _M_ready && !_M_error;
+    }
+
+    void
+    wait()
+    {
+      std::unique_lock<std::mutex> __lock(_M_mutex);
+      if (!_M_ready)
+        _M_cond.wait(__lock, std::bind(&_Future_state_base::_M_ready, this));
+    }
+
+    template<typename _Rep, typename _Period>
+      bool
+      wait_for(const chrono::duration<_Rep, _Period>& __rel)
+      {
+        std::unique_lock<std::mutex> __lock(_M_mutex);
+        return _M_ready || _M_cond.wait_for(__lock, __rel,
+            std::bind(&_Future_state_base::_M_ready, this));
+      }
+
+    template<typename _Clock, typename _Duration>
+      bool
+      wait_until(const chrono::time_point<_Clock, _Duration>& __abs)
+      {
+        std::unique_lock<std::mutex> __lock(_M_mutex);
+        return _M_ready || _M_cond.wait_until(__lock, __abs,
+            std::bind(&_Future_state_base::_M_ready, this));
+      }
+
+    void
+    _M_break_promise()
+    {
+      {
+        std::lock_guard<std::mutex> __lock(_M_mutex);
+        if (_M_ready)
+          return;  // already satisfied
+        _M_error = copy_exception(future_error(future_errc::broken_promise));
+        _M_ready = true;
+      }
+      _M_notify();
+    }
+
+    void
+    _M_set_exception(exception_ptr __p)
+    {
+      {
+        std::lock_guard<std::mutex> __lock(_M_mutex);
+        _M_set_ready_flag(__lock);
+        _M_error = __p;
+      }
+      _M_notify();
+    }
+
+    // called when this object is passed to a unique_future
+    void
+    _M_set_retrieved_flag()
+    {
+      std::lock_guard<std::mutex> __lock(_M_mutex);
+      if (_M_retrieved)
+        throw future_error(future_errc::future_already_retrieved);
+      _M_retrieved = true;
+    }
+
+    // wait for result and propagate any stored exception
+    void
+    _M_wait_and_check(std::unique_lock<std::mutex>& __lock)
+    {
+      if (!_M_ready)
+        _M_cond.wait(__lock, std::bind(&_Future_state_base::_M_ready, this));
+      if (_M_error)
+        std::rethrow_exception(_M_error);
+    }
+
+    // called before setting a result (either a value or an exception)
+    void
+    _M_set_ready_flag(const std::lock_guard<std::mutex>&)
+    {
+      if (_M_ready)
+        throw future_error(future_errc::promise_already_satisfied);
+      _M_ready = true;
+    }
+
+    void _M_notify() { _M_cond.notify_all(); }
+  };
+
+  // State shared between a promise and one or more futures.
+  template<typename _Result>
+    struct _Future_state : _Future_state_base
+    {
+      _Future_state() : _Future_state_base() { }
+
+      typename std::remove_reference<_Result>::type _M_result;
+    };
+
+  // partial specialization for promise<R&>
+  template<typename _Result>
+    struct _Future_state<_Result&> : _Future_state_base
+    {
+      _Future_state() : _Future_state_base() { }
+
+      _Result* _M_result;
+    };
+
+  template<>
+    struct _Future_state<void> : _Future_state_base
+    {
+      _Future_state() : _Future_state_base() { }
+    };
+
+  /// unique_future
+  template<typename _Result>
+    class unique_future;
+
+  /// shared_future
+  template<typename _Result>
+    class shared_future;
+
+  // common implementation for unique_future and shared_future
+  template<typename _Result>
+    class _Future_impl
+    {
+    protected:
+      typedef std::shared_ptr<_Future_state<_Result>> _State_ptr;
+
+      // construction of a unique_future by promise::get_future()
+      _Future_impl(const _State_ptr& __state)
+      : _M_state(__state)
+      {
+        if (_M_state)
+          _M_state->_M_set_retrieved_flag();
+        else
+          throw future_error(future_errc::future_already_retrieved);
+      }
+
+      // copy construction from a shared_future
+      _Future_impl(const shared_future<_Result>&);
+
+      // move construction from a unique_future
+      _Future_impl(unique_future<_Result>&&);
+
+      // disable copying
+      _Future_impl(const _Future_impl&) = delete;
+      _Future_impl& operator=(const _Future_impl&) = delete;
+
+    public:
+      // functions to check state and wait for ready
+      bool is_ready() const { return _M_state->is_ready(); }
+
+      bool has_exception() const { return _M_state->has_exception(); }
+
+      bool has_value() const { return _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:
+      _State_ptr _M_state;
+    };
+
+  /// promise
+  template<typename _Result>
+    class promise;
+
+  // primary template for unique_future
+  template<typename _Result>
+    class unique_future : public _Future_impl<_Result>
+    {
+      typedef _Future_impl<_Result> _Base_type;
+
+    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()
+      {
+        std::unique_lock<std::mutex> __lock(this->_M_state->_M_mutex);
+        this->_M_state->_M_wait_and_check(__lock);
+        return std::move(this->_M_state->_M_result);
+      }
+
+    private:
+      friend class promise<_Result>;
+#if 0
+      // c++/40007
+      typedef typename _Base_type::_State_ptr _State_ptr;
+
+      explicit
+      unique_future(const _State_ptr& __state) : _Base_type(__state) { }
+#else
+      explicit
+      unique_future(const std::shared_ptr<_Future_state<_Result>>& __state)
+      : _Base_type(__state)
+      { }
+#endif
+    };
+ 
+  // partial specialization for unique_future<R&>
+  template<typename _Result>
+    class unique_future<_Result&> : public _Future_impl<_Result&>
+    {
+      typedef _Future_impl<_Result&> _Base_type;
+
+    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()
+      {
+        std::unique_lock<std::mutex> __lock(this->_M_state->_M_mutex);
+        this->_M_state->_M_wait_and_check(__lock);
+        return *this->_M_state->_M_result;
+      }
+
+    private:
+      friend class promise<_Result&>;
+#if 0
+      // c++/40007
+      typedef typename _Base_type::_State_ptr _State_ptr;
+
+      explicit
+      unique_future(const _State_ptr& __state) : _Base_type(__state) { }
+#else
+      explicit
+      unique_future(const std::shared_ptr<_Future_state<_Result&>>& __state)
+      : _Base_type(__state)
+      { }
+#endif
+    };
+
+  // specialization for unique_future<void>
+  template<>
+    class unique_future<void> : public _Future_impl<void>
+    {
+      typedef _Future_impl<void> _Base_type;
+
+    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()
+      {
+        std::unique_lock<std::mutex> __lock(this->_M_state->_M_mutex);
+        this->_M_state->_M_wait_and_check(__lock);
+      }
+
+    private:
+      friend class promise<void>;
+#if 0
+      // c++/40007
+      typedef _Base_type::_State_ptr _State_ptr;
+
+      explicit
+      unique_future(const _State_ptr& __state) : _Base_type(__state) { }
+#else
+      explicit
+      unique_future(const std::shared_ptr<_Future_state<void>>& __state)
+      : _Base_type(__state)
+      { }
+#endif
+    };
+
+  // primary template for unique_future
+  template<typename _Result>
+    class shared_future : public _Future_impl<_Result>
+    {
+      typedef _Future_impl<_Result> _Base_type;
+
+    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()
+      {
+        std::unique_lock<std::mutex> __lock(this->_M_state->_M_mutex);
+        this->_M_state->_M_wait_and_check(__lock);
+        return this->_M_state->_M_result;
+      }
+    };
+ 
+  // partial specialization for shared_future<R&>
+  template<typename _Result>
+    class shared_future<_Result&> : public _Future_impl<_Result&>
+    {
+      typedef _Future_impl<_Result&> _Base_type;
+
+    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()
+      {
+        std::unique_lock<std::mutex> __lock(this->_M_state->_M_mutex);
+        this->_M_state->_M_wait_and_check(__lock);
+        return *this->_M_state->_M_result;
+      }
+    };
+
+  // specialization for shared_future<void>
+  template<>
+    class shared_future<void> : public _Future_impl<void>
+    {
+      typedef _Future_impl<void> _Base_type;
+
+    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()
+      {
+        std::unique_lock<std::mutex> __lock(this->_M_state->_M_mutex);
+        this->_M_state->_M_wait_and_check(__lock);
+      }
+    };
+
+  // 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<_Result>>()) { }
+
+#if 0
+      template<typename _Allocator>
+        promise(allocator_arg_t, const _Allocator& __a);
+        : _M_future(std::allocate_shared<_Future_state<_Result>>(__a))
+        { }
+#endif
+
+      promise(promise&& __rhs) : _M_future(std::move(__rhs._M_future)) { }
+
+#if 0
+      template<typename _Allocator>
+        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
+        : _M_future(std::move(__rhs._M_future))
+        { }
+#endif
+
+      promise(const promise&) = delete;
+
+      ~promise()
+      {
+        if (_M_future && !_M_future.unique())
+          _M_future->_M_break_promise();
+      }
+
+      // 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); }
+
+      // retrieving the result
+      unique_future<_Result>
+      get_future()
+      { return unique_future<_Result>(_M_future); }
+
+      // setting the result
+      void set_value(const _Result& __r)
+      {
+        {
+          std::lock_guard<std::mutex> __lock(_M_future->_M_mutex);
+          _M_future->_M_set_ready_flag(__lock);
+          _M_future->_M_result = __r;
+        }
+        _M_future->_M_notify();
+      }
+
+      void set_value(_Result&& __r)
+      {
+        {
+          std::lock_guard<std::mutex> __lock(_M_future->_M_mutex);
+          _M_future->_M_set_ready_flag(__lock);
+          _M_future->_M_result = std::move(__r);
+        }
+        _M_future->_M_notify();
+      }
+
+      void set_exception(exception_ptr __p)
+      { _M_future->_M_set_exception(__p); }
+
+    private:
+      std::shared_ptr<_Future_state<_Result>> _M_future;
+    };
+
+  // partial specialization for promise<R&>
+  template<typename _Result>
+    class promise<_Result&>
+    {
+    public:
+      promise() : _M_future(std::make_shared<_Future_state<_Result&>>()) { }
+
+#if 0
+      template<typename _Allocator>
+        promise(allocator_arg_t, const _Allocator& __a)
+        : _M_future(std::allocate_shared<_Future_state<_Result&>>(__a))
+        { }
+#endif
+
+      promise(promise&& __rhs) : _M_future(std::move(__rhs._M_future)) { }
+
+#if 0
+      template<typename _Allocator>
+        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
+        : _M_future(std::move(__rhs._M_future))
+        { }
+#endif
+
+      promise(const promise&) = delete;
+
+      ~promise()
+      {
+        if (_M_future && !_M_future.unique())
+          _M_future->_M_break_promise();
+      }
+
+      // 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); }
+
+      // retrieving the result
+      unique_future<_Result&>
+      get_future()
+      { return unique_future<_Result&>(_M_future); }
+
+      // setting the result
+      void set_value(_Result& __r)
+      {
+        {
+          std::lock_guard<std::mutex> __lock(_M_future->_M_mutex);
+          _M_future->_M_set_ready_flag(__lock);
+          _M_future->_M_result = &__r;
+        }
+        _M_future->_M_notify();
+      }
+
+      void set_exception(exception_ptr __p)
+      { _M_future->_M_set_exception(__p); }
+
+    private:
+      std::shared_ptr<_Future_state<_Result&>> _M_future;
+    };
+
+  // specialization for promise<void>
+  template<>
+    class promise<void>
+    {
+    public:
+      promise() : _M_future(std::make_shared<_Future_state<void>>()) { }
+
+#if 0
+      template<typename _Allocator>
+        promise(allocator_arg_t, const _Allocator& __a)
+        : _M_future(std::allocate_shared<_Future_state<void>>(__a))
+        { }
+#endif
+
+      promise(promise&& __rhs) : _M_future(std::move(__rhs._M_future)) { }
+
+#if 0
+      template<typename _Allocator>
+        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
+        : _M_future(std::move(__rhs._M_future))
+        { }
+#endif
+
+      promise(const promise&) = delete;
+
+      ~promise()
+      {
+        if (_M_future && !_M_future.unique())
+          _M_future->_M_break_promise();
+      }
+
+      // 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); }
+
+      // retrieving the result
+      unique_future<void>
+      get_future()
+      { return unique_future<void>(_M_future); }
+
+      // setting the result
+      void set_value()
+      {
+        {
+          std::lock_guard<std::mutex> __lock(_M_future->_M_mutex);
+          _M_future->_M_set_ready_flag(__lock);
+        }
+        _M_future->_M_notify();
+      }
+
+      void set_exception(exception_ptr __p)
+      { _M_future->_M_set_exception(__p); }
+
+    private:
+      std::shared_ptr<_Future_state<void>> _M_future;
+    };
+
+#if 0
+  template<typename _Result, class Alloc>
+    concept_map UsesAllocator<promise<_Result>, Alloc>
+    {
+      typedef Alloc allocator_type;
+    }
+#endif
+
+  template<typename _Result, typename... _ArgTypes>
+    class _Run_task
+    {
+      typedef std::promise<_Result> _Prom;
+
+    public:
+      void
+      _M_run(_Prom& __p, std::function<_Result(_ArgTypes...)>& __f,
+          _ArgTypes... __args) const
+      {
+        __p.set_value(__f(std::forward<_ArgTypes>(__args)...));
+      }
+    };
+
+  // specialization used by packaged_task<void(...)>
+  template<typename... _ArgTypes>
+    class _Run_task<void, _ArgTypes...>
+    {
+      typedef std::promise<void> _Prom;
+
+    public:
+      void
+      _M_run(_Prom& __p, std::function<void(_ArgTypes...)>& __f,
+          _ArgTypes... __args) const
+      {
+        __f(std::forward<_ArgTypes>(__args)...);
+        __p.set_value();
+      }
+    };
+
+  template<typename> class packaged_task; // unde�ned
+
+  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) { }
+
+#if 0
+      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)
+        { }
+#endif
+
+      explicit
+      packaged_task(_Result(*__fn)(_ArgTypes...)) : _M_task(__fn) { }
+
+      template<typename _Fn>
+        explicit packaged_task(_Fn&& __fn) : _M_task(std::move(__fn)) { }
+
+#if 0
+      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)
+        { }
+#endif
+
+      ~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);
+      }
+
+#if 0
+      explicit operator bool() const { return bool(_M_task); }
+#else
+    private:
+      void _M_dummy() const { }
+    public:
+      typedef void (packaged_task::*__safe_bool_type)() const;
+      operator __safe_bool_type() const
+      { return _M_task ? &packaged_task::_M_dummy : 0; }
+#endif
+
+      // 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 (!_M_task)
+          throw std::bad_function_call();
+        try
+        {
+          _Run_task<_Result, _ArgTypes...>()._M_run(_M_promise,
+              _M_task, std::forward<_ArgTypes>(__args)...);
+        }
+        catch (...)
+        {
+          _M_promise.set_exception(current_exception());
+        }
+        std::function<_Result(_ArgTypes...)>().swap(_M_task);
+      }
+
+      void reset() { packaged_task(std::move(_M_task)).swap(*this); }
+
+    private:
+      std::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
Index: src/future.cc
===================================================================
--- src/future.cc	(revision 0)
+++ src/future.cc	(revision 0)
@@ -0,0 +1,70 @@
+// 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;
+      }
+      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
Index: testsuite/30_threads/packaged_task/cons/assign_neg.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/assign_neg.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/cons/assign_neg.cc	(revision 0)
@@ -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 *-*-* } 801 }
Index: testsuite/30_threads/packaged_task/cons/1.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/1.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/cons/1.cc	(revision 0)
@@ -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>
+#include <testsuite_tr1.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  using std::packaged_task;
+  using namespace __gnu_test;
+
+  packaged_task<int ()> p1;
+  VERIFY( !p1 );
+  packaged_task<int& ()> p2;
+  VERIFY( !p2 );
+  packaged_task<void ()> p3;
+  VERIFY( !p3 );
+  packaged_task<ClassType ()> p4;
+  VERIFY( !p4 );
+  packaged_task<AbstractClass& (int)> p5;
+  VERIFY( !p5 );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/cons/2.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/2.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/cons/2.cc	(revision 0)
@@ -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>
+#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;
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  using std::packaged_task;
+
+  packaged_task<int ()> p1(f1);
+  VERIFY( p1 );
+  packaged_task<int& ()> p2(f2);
+  VERIFY( p2 );
+  packaged_task<void ()> p3(f3);
+  VERIFY( p3 );
+  packaged_task<ClassType ()> p4(f4);
+  VERIFY( p4 );
+  packaged_task<AbstractClass& (int)> p5(f5);
+  VERIFY( p5 );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/cons/copy_neg.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/copy_neg.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/cons/copy_neg.cc	(revision 0)
@@ -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 *-*-* } 800 }
Index: testsuite/30_threads/packaged_task/cons/move.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/move.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/cons/move.cc	(revision 0)
@@ -0,0 +1,44 @@
+// { 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; }
+
+int main()
+{
+  using namespace std;
+
+  // move
+  packaged_task<int()> p1(f1);
+  packaged_task<int()> p2(std::move(p1));
+  VERIFY( !p1 );
+  VERIFY( p2 );
+
+  return 0;
+}
+
Index: testsuite/30_threads/packaged_task/cons/move_assign.cc
===================================================================
--- testsuite/30_threads/packaged_task/cons/move_assign.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/cons/move_assign.cc	(revision 0)
@@ -0,0 +1,43 @@
+// { 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; }
+
+int main()
+{
+  // move assign
+  std::packaged_task<int()> p1;
+  std::packaged_task<int()> p2(gen);
+  p1 = std::move(p2);
+  VERIFY( p1 );
+  VERIFY( !p2 );
+
+  return 0;
+}
+
Index: testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/requirements/explicit_instantiation.cc	(revision 0)
@@ -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)>;
Index: testsuite/30_threads/packaged_task/members/invoke.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/invoke.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/invoke.cc	(revision 0)
@@ -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 <system_error>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::packaged_task<int()> p1(zero);
+  std::unique_future<int> f1 = p1.get_future();
+
+  p1();
+  p1.reset();
+
+  VERIFY( !p1 );
+  VERIFY( f1.has_value() );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/get_future2.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/get_future2.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/get_future2.cc	(revision 0)
@@ -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 <system_error>
+#include <testsuite_hooks.h>
+
+int& inc(int& i) { return ++i; }
+
+int main()
+{
+  bool test __attribute__((unused)) = 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 );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/invoke2.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/invoke2.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/invoke2.cc	(revision 0)
@@ -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>
+
+bool odd(unsigned i) { return i%2; }
+
+int main()
+{
+  bool test __attribute__((unused)) = false;
+
+  std::packaged_task<bool(unsigned)> p1(odd);
+  std::unique_future<bool> f1 = p1.get_future();
+
+  p1(5);
+
+  try
+  {
+    p1(4);
+  }
+  catch (std::bad_function_call&)
+  {
+    test = true;
+  }
+
+  VERIFY( test );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/boolconv.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/boolconv.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/boolconv.cc	(revision 0)
@@ -0,0 +1,43 @@
+// { 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; }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::packaged_task<int()> p1;
+  VERIFY( !p1 );
+
+  std::packaged_task<int()> p2(zero);
+  VERIFY( p2 );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/reset.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/reset.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/reset.cc	(revision 0)
@@ -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 zero() { return 0; }
+
+int main()
+{
+  bool test __attribute__((unused)) = false;
+  using namespace std;
+
+  packaged_task<int()> p1(zero);
+  unique_future<int> f1 = p1.get_future();
+  VERIFY( p1 );
+  p1.reset();
+  VERIFY( p1 );
+  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 );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/reset2.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/reset2.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/reset2.cc	(revision 0)
@@ -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 <system_error>
+#include <testsuite_hooks.h>
+
+int zero() { return 0; }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::packaged_task<int()> p1(zero);
+  std::unique_future<int> f1 = p1.get_future();
+
+  p1();
+  p1.reset();
+
+  VERIFY( !p1 );
+  VERIFY( f1.has_value() );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/get_future.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/get_future.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/get_future.cc	(revision 0)
@@ -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>
+
+int& inc(int& i) { return ++i; }
+
+int main()
+{
+  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 );
+
+  return 0;
+}
Index: testsuite/30_threads/packaged_task/members/swap.cc
===================================================================
--- testsuite/30_threads/packaged_task/members/swap.cc	(revision 0)
+++ testsuite/30_threads/packaged_task/members/swap.cc	(revision 0)
@@ -0,0 +1,45 @@
+// { 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; }
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::packaged_task<int()> p1(zero);
+  std::packaged_task<int()> p2;
+  VERIFY( p1 );
+  VERIFY( !p2 );
+  p1.swap(p2);
+  VERIFY( !p1 );
+  VERIFY( p2 );
+
+  return 0;
+}
Index: testsuite/30_threads/promise/cons/assign_neg.cc
===================================================================
--- testsuite/30_threads/promise/cons/assign_neg.cc	(revision 0)
+++ testsuite/30_threads/promise/cons/assign_neg.cc	(revision 0)
@@ -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 *-*-* } 554 }
Index: testsuite/30_threads/promise/cons/1.cc
===================================================================
--- testsuite/30_threads/promise/cons/1.cc	(revision 0)
+++ testsuite/30_threads/promise/cons/1.cc	(revision 0)
@@ -0,0 +1,43 @@
+// { 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>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  using std::promise;
+  using namespace __gnu_test;
+
+  promise<int> p1;
+  promise<int&> p2;
+  promise<void> p3;
+  promise<ClassType> p4;
+  promise<AbstractClass&> p5;
+
+  return 0;
+}
Index: testsuite/30_threads/promise/cons/copy_neg.cc
===================================================================
--- testsuite/30_threads/promise/cons/copy_neg.cc	(revision 0)
+++ testsuite/30_threads/promise/cons/copy_neg.cc	(revision 0)
@@ -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 *-*-* } 538 }
Index: testsuite/30_threads/promise/cons/move.cc
===================================================================
--- testsuite/30_threads/promise/cons/move.cc	(revision 0)
+++ testsuite/30_threads/promise/cons/move.cc	(revision 0)
@@ -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>
+
+int main()
+{
+  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));
+  }
+
+  return 0;
+}
+
Index: testsuite/30_threads/promise/cons/move_assign.cc
===================================================================
--- testsuite/30_threads/promise/cons/move_assign.cc	(revision 0)
+++ testsuite/30_threads/promise/cons/move_assign.cc	(revision 0)
@@ -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>
+
+int main()
+{
+  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));
+  }
+
+  return 0;
+}
+
Index: testsuite/30_threads/promise/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/30_threads/promise/requirements/explicit_instantiation.cc	(revision 0)
+++ testsuite/30_threads/promise/requirements/explicit_instantiation.cc	(revision 0)
@@ -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&>;
Index: testsuite/30_threads/promise/members/get_future2.cc
===================================================================
--- testsuite/30_threads/promise/members/get_future2.cc	(revision 0)
+++ testsuite/30_threads/promise/members/get_future2.cc	(revision 0)
@@ -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 <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = 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 );
+
+  return 0;
+}
Index: testsuite/30_threads/promise/members/set_value.cc
===================================================================
--- testsuite/30_threads/promise/members/set_value.cc	(revision 0)
+++ testsuite/30_threads/promise/members/set_value.cc	(revision 0)
@@ -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;
+}
Index: testsuite/30_threads/promise/members/get_future.cc
===================================================================
--- testsuite/30_threads/promise/members/get_future.cc	(revision 0)
+++ testsuite/30_threads/promise/members/get_future.cc	(revision 0)
@@ -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>
+
+int main()
+{
+  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 );
+
+  return 0;
+}
Index: testsuite/30_threads/promise/members/set_exception.cc
===================================================================
--- testsuite/30_threads/promise/members/set_exception.cc	(revision 0)
+++ testsuite/30_threads/promise/members/set_exception.cc	(revision 0)
@@ -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>
+
+int main()
+{
+  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() );
+
+  return 0;
+}
+
Index: testsuite/30_threads/promise/members/swap.cc
===================================================================
--- testsuite/30_threads/promise/members/swap.cc	(revision 0)
+++ testsuite/30_threads/promise/members/swap.cc	(revision 0)
@@ -0,0 +1,42 @@
+// { 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 main()
+{
+  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() );
+
+  return 0;
+}
Index: testsuite/30_threads/unique_future/cons/assign_neg.cc
===================================================================
--- testsuite/30_threads/unique_future/cons/assign_neg.cc	(revision 0)
+++ testsuite/30_threads/unique_future/cons/assign_neg.cc	(revision 0)
@@ -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 *-*-* } 320 }
Index: testsuite/30_threads/unique_future/cons/default_neg.cc
===================================================================
--- testsuite/30_threads/unique_future/cons/default_neg.cc	(revision 0)
+++ testsuite/30_threads/unique_future/cons/default_neg.cc	(revision 0)
@@ -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_tr1.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  using std::unique_future;
+  using namespace __gnu_test;
+
+  unique_future<int> p1;                // { dg-error "no match" }
+  unique_future<int&> p2;               // { dg-error "no match" }
+  unique_future<void> p3;               // { dg-error "no match" }
+  unique_future<ClassType> p4;          // { dg-error "no match" }
+  unique_future<AbstractClass&> p5;     // { dg-error "no match" }
+
+  return 0;
+}
+// { dg-excess-errors "note" }
Index: testsuite/30_threads/unique_future/cons/copy_neg.cc
===================================================================
--- testsuite/30_threads/unique_future/cons/copy_neg.cc	(revision 0)
+++ testsuite/30_threads/unique_future/cons/copy_neg.cc	(revision 0)
@@ -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 *-*-* } 319 }
Index: testsuite/30_threads/unique_future/cons/move.cc
===================================================================
--- testsuite/30_threads/unique_future/cons/move.cc	(revision 0)
+++ testsuite/30_threads/unique_future/cons/move.cc	(revision 0)
@@ -0,0 +1,38 @@
+// { 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>
+
+int main()
+{
+  // move
+  std::promise<int> p1;
+  std::unique_future<int> f1(p1.get_future());
+  std::unique_future<int> f2(std::move(f1));
+
+  return 0;
+}
+
Index: testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc	(revision 0)
+++ testsuite/30_threads/unique_future/requirements/explicit_instantiation.cc	(revision 0)
@@ -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&>;
Index: testsuite/30_threads/unique_future/members/get.cc
===================================================================
--- testsuite/30_threads/unique_future/members/get.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/get.cc	(revision 0)
@@ -0,0 +1,66 @@
+// { 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()
+{
+  std::promise<int> p1;
+  std::unique_future<int> f1(p1.get_future());
+
+  p1.set_value(value);
+  VERIFY( f1.get() == value );
+}
+
+void test02()
+{
+  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;
+}
Index: testsuite/30_threads/unique_future/members/is_ready.cc
===================================================================
--- testsuite/30_threads/unique_future/members/is_ready.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/is_ready.cc	(revision 0)
@@ -0,0 +1,42 @@
+// { 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 main()
+{
+  std::promise<int> p1;
+  std::unique_future<int> f1(p1.get_future());
+
+  VERIFY( !f1.is_ready() );
+
+  p1.set_value(1);
+
+  VERIFY( f1.is_ready() );
+
+  return 0;
+}
Index: testsuite/30_threads/unique_future/members/wait_until.cc
===================================================================
--- testsuite/30_threads/unique_future/members/wait_until.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/wait_until.cc	(revision 0)
@@ -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 <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);
+}
+
+int main()
+{
+  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 );
+
+  return 0;
+}
Index: testsuite/30_threads/unique_future/members/get2.cc
===================================================================
--- testsuite/30_threads/unique_future/members/get2.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/get2.cc	(revision 0)
@@ -0,0 +1,91 @@
+// { 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()
+{
+  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()
+{
+  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()
+{
+  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;
+}
Index: testsuite/30_threads/unique_future/members/wait.cc
===================================================================
--- testsuite/30_threads/unique_future/members/wait.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/wait.cc	(revision 0)
@@ -0,0 +1,50 @@
+// { 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();
+}
+
+int main()
+{
+  std::promise<void> p1;
+  std::unique_future<void> f1(p1.get_future());
+
+  std::thread t1(wait, std::ref(f1));
+
+  p1.set_value();
+  t1.join();
+
+  return 0;
+}
Index: testsuite/30_threads/unique_future/members/has_value.cc
===================================================================
--- testsuite/30_threads/unique_future/members/has_value.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/has_value.cc	(revision 0)
@@ -0,0 +1,61 @@
+// { 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()
+{
+  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()
+{
+  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;
+}
+
Index: testsuite/30_threads/unique_future/members/has_exception.cc
===================================================================
--- testsuite/30_threads/unique_future/members/has_exception.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/has_exception.cc	(revision 0)
@@ -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>
+
+void test01()
+{
+  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()
+{
+  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;
+}
Index: testsuite/30_threads/unique_future/members/wait_for.cc
===================================================================
--- testsuite/30_threads/unique_future/members/wait_for.cc	(revision 0)
+++ testsuite/30_threads/unique_future/members/wait_for.cc	(revision 0)
@@ -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 <chrono>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  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) );
+
+  return 0;
+}
Index: testsuite/30_threads/shared_future/cons/assign_neg.cc
===================================================================
--- testsuite/30_threads/shared_future/cons/assign_neg.cc	(revision 0)
+++ testsuite/30_threads/shared_future/cons/assign_neg.cc	(revision 0)
@@ -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 *-*-* } 438 }
Index: testsuite/30_threads/shared_future/cons/default_neg.cc
===================================================================
--- testsuite/30_threads/shared_future/cons/default_neg.cc	(revision 0)
+++ testsuite/30_threads/shared_future/cons/default_neg.cc	(revision 0)
@@ -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_tr1.h>
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  using std::shared_future;
+  using namespace __gnu_test;
+
+  shared_future<int> p1;                // { dg-error "no match" }
+  shared_future<int&> p2;               // { dg-error "no match" }
+  shared_future<void> p3;               // { dg-error "no match" }
+  shared_future<ClassType> p4;          // { dg-error "no match" }
+  shared_future<AbstractClass&> p5;     // { dg-error "no match" }
+
+  return 0;
+}
+// { dg-excess-errors "note" }
Index: testsuite/30_threads/shared_future/cons/move.cc
===================================================================
--- testsuite/30_threads/shared_future/cons/move.cc	(revision 0)
+++ testsuite/30_threads/shared_future/cons/move.cc	(revision 0)
@@ -0,0 +1,38 @@
+// { 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>
+
+int main()
+{
+  // 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));
+
+  return 0;
+}
+
Index: testsuite/30_threads/shared_future/cons/copy.cc
===================================================================
--- testsuite/30_threads/shared_future/cons/copy.cc	(revision 0)
+++ testsuite/30_threads/shared_future/cons/copy.cc	(revision 0)
@@ -0,0 +1,39 @@
+// { 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();
+
+int main()
+{
+  bool test __attribute__((unused)) = true;
+  using std::shared_future;
+
+  shared_future<int> p1 = get();
+  shared_future<int> p2(p1);
+
+  return 0;
+}
Index: testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc	(revision 0)
+++ testsuite/30_threads/shared_future/requirements/explicit_instantiation.cc	(revision 0)
@@ -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&>;
Index: testsuite/30_threads/shared_future/members/get.cc
===================================================================
--- testsuite/30_threads/shared_future/members/get.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/get.cc	(revision 0)
@@ -0,0 +1,72 @@
+// { 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()
+{
+  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()
+{
+  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()
+{
+  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;
+}
Index: testsuite/30_threads/shared_future/members/is_ready.cc
===================================================================
--- testsuite/30_threads/shared_future/members/is_ready.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/is_ready.cc	(revision 0)
@@ -0,0 +1,45 @@
+// { 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 main()
+{
+  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() );
+
+  return 0;
+}
Index: testsuite/30_threads/shared_future/members/wait_until.cc
===================================================================
--- testsuite/30_threads/shared_future/members/wait_until.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/wait_until.cc	(revision 0)
@@ -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);
+}
+
+int main()
+{
+  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 );
+
+  return 0;
+}
Index: testsuite/30_threads/shared_future/members/get2.cc
===================================================================
--- testsuite/30_threads/shared_future/members/get2.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/get2.cc	(revision 0)
@@ -0,0 +1,121 @@
+// { 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;
+
+int main()
+{
+  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()
+{
+  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()
+{
+  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;
+}
Index: testsuite/30_threads/shared_future/members/wait.cc
===================================================================
--- testsuite/30_threads/shared_future/members/wait.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/wait.cc	(revision 0)
@@ -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 <thread>
+#include <mutex>
+#include <testsuite_hooks.h>
+
+void wait(std::shared_future<void> f)
+{
+  f.wait();
+}
+
+int main()
+{
+  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();
+
+  return 0;
+}
+
Index: testsuite/30_threads/shared_future/members/has_value.cc
===================================================================
--- testsuite/30_threads/shared_future/members/has_value.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/has_value.cc	(revision 0)
@@ -0,0 +1,66 @@
+// { 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()
+{
+  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()
+{
+  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;
+}
Index: testsuite/30_threads/shared_future/members/has_exception.cc
===================================================================
--- testsuite/30_threads/shared_future/members/has_exception.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/has_exception.cc	(revision 0)
@@ -0,0 +1,66 @@
+// { 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()
+{
+  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;
+  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;
+}
Index: testsuite/30_threads/shared_future/members/wait_for.cc
===================================================================
--- testsuite/30_threads/shared_future/members/wait_for.cc	(revision 0)
+++ testsuite/30_threads/shared_future/members/wait_for.cc	(revision 0)
@@ -0,0 +1,50 @@
+// { 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>
+
+int main()
+{
+  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) );
+
+  return 0;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]