OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [libstdc++-v3/] [include/] [std/] [future] - Diff between revs 742 and 783

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 742 Rev 783
//  -*- C++ -*-
//  -*- C++ -*-
// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
//
//
// This file is part of the GNU ISO C++ Library.  This library is free
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// any later version.
// This library is distributed in the hope that it will be useful,
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// 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;
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// .
// .
/** @file include/future
/** @file include/future
 *  This is a Standard C++ Library header.
 *  This is a Standard C++ Library header.
 */
 */
#ifndef _GLIBCXX_FUTURE
#ifndef _GLIBCXX_FUTURE
#define _GLIBCXX_FUTURE 1
#define _GLIBCXX_FUTURE 1
#pragma GCC system_header
#pragma GCC system_header
#ifndef __GXX_EXPERIMENTAL_CXX0X__
#ifndef __GXX_EXPERIMENTAL_CXX0X__
# include 
# include 
#else
#else
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
namespace std _GLIBCXX_VISIBILITY(default)
namespace std _GLIBCXX_VISIBILITY(default)
{
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_VERSION
  /**
  /**
   * @defgroup futures Futures
   * @defgroup futures Futures
   * @ingroup concurrency
   * @ingroup concurrency
   *
   *
   * Classes for futures support.
   * Classes for futures support.
   * @{
   * @{
   */
   */
  /// Error code for futures
  /// Error code for futures
  enum class future_errc
  enum class future_errc
  {
  {
    future_already_retrieved = 1,
    future_already_retrieved = 1,
    promise_already_satisfied,
    promise_already_satisfied,
    no_state,
    no_state,
    broken_promise
    broken_promise
  };
  };
  /// Specialization.
  /// Specialization.
  template<>
  template<>
    struct is_error_code_enum : public true_type { };
    struct is_error_code_enum : public true_type { };
  /// Points to a statically-allocated object derived from error_category.
  /// Points to a statically-allocated object derived from error_category.
  const error_category&
  const error_category&
  future_category() noexcept;
  future_category() noexcept;
  /// Overload for make_error_code.
  /// Overload for make_error_code.
  inline error_code
  inline error_code
  make_error_code(future_errc __errc) noexcept
  make_error_code(future_errc __errc) noexcept
  { return error_code(static_cast(__errc), future_category()); }
  { return error_code(static_cast(__errc), future_category()); }
  /// Overload for make_error_condition.
  /// Overload for make_error_condition.
  inline error_condition
  inline error_condition
  make_error_condition(future_errc __errc) noexcept
  make_error_condition(future_errc __errc) noexcept
  { return error_condition(static_cast(__errc), future_category()); }
  { return error_condition(static_cast(__errc), future_category()); }
  /**
  /**
   *  @brief Exception type thrown by futures.
   *  @brief Exception type thrown by futures.
   *  @ingroup exceptions
   *  @ingroup exceptions
   */
   */
  class future_error : public logic_error
  class future_error : public logic_error
  {
  {
    error_code                  _M_code;
    error_code                  _M_code;
  public:
  public:
    explicit future_error(error_code __ec)
    explicit future_error(error_code __ec)
    : logic_error("std::future_error"), _M_code(__ec)
    : logic_error("std::future_error"), _M_code(__ec)
    { }
    { }
    virtual ~future_error() noexcept;
    virtual ~future_error() noexcept;
    virtual const char*
    virtual const char*
    what() const noexcept;
    what() const noexcept;
    const error_code&
    const error_code&
    code() const noexcept { return _M_code; }
    code() const noexcept { return _M_code; }
  };
  };
  // Forward declarations.
  // Forward declarations.
  template
  template
    class future;
    class future;
  template
  template
    class shared_future;
    class shared_future;
  template
  template
    class atomic_future;
    class atomic_future;
  template
  template
    class packaged_task;
    class packaged_task;
  template
  template
    class promise;
    class promise;
  /// Launch code for futures
  /// Launch code for futures
  enum class launch
  enum class launch
  {
  {
    async = 1,
    async = 1,
    deferred = 2
    deferred = 2
  };
  };
  constexpr launch operator&(launch __x, launch __y)
  constexpr launch operator&(launch __x, launch __y)
  {
  {
    return static_cast(
    return static_cast(
        static_cast(__x) & static_cast(__y));
        static_cast(__x) & static_cast(__y));
  }
  }
  constexpr launch operator|(launch __x, launch __y)
  constexpr launch operator|(launch __x, launch __y)
  {
  {
    return static_cast(
    return static_cast(
        static_cast(__x) | static_cast(__y));
        static_cast(__x) | static_cast(__y));
  }
  }
  constexpr launch operator^(launch __x, launch __y)
  constexpr launch operator^(launch __x, launch __y)
  {
  {
    return static_cast(
    return static_cast(
        static_cast(__x) ^ static_cast(__y));
        static_cast(__x) ^ static_cast(__y));
  }
  }
  constexpr launch operator~(launch __x)
  constexpr launch operator~(launch __x)
  { return static_cast(~static_cast(__x)); }
  { return static_cast(~static_cast(__x)); }
  inline launch& operator&=(launch& __x, launch __y)
  inline launch& operator&=(launch& __x, launch __y)
  { return __x = __x & __y; }
  { return __x = __x & __y; }
  inline launch& operator|=(launch& __x, launch __y)
  inline launch& operator|=(launch& __x, launch __y)
  { return __x = __x | __y; }
  { return __x = __x | __y; }
  inline launch& operator^=(launch& __x, launch __y)
  inline launch& operator^=(launch& __x, launch __y)
  { return __x = __x ^ __y; }
  { return __x = __x ^ __y; }
  /// Status code for futures
  /// Status code for futures
  enum class future_status
  enum class future_status
  {
  {
    ready,
    ready,
    timeout,
    timeout,
    deferred
    deferred
  };
  };
  template
  template
    future::type>
    future::type>
    async(launch __policy, _Fn&& __fn, _Args&&... __args);
    async(launch __policy, _Fn&& __fn, _Args&&... __args);
  template
  template
    struct __async_sfinae_helper
    struct __async_sfinae_helper
    {
    {
      typedef future::type> type;
      typedef future::type> type;
    };
    };
  template
  template
    struct __async_sfinae_helper
    struct __async_sfinae_helper
    { };
    { };
  template
  template
    typename
    typename
    __async_sfinae_helper::type, _Fn, _Args...>::type
    __async_sfinae_helper::type, _Fn, _Args...>::type
    async(_Fn&& __fn, _Args&&... __args);
    async(_Fn&& __fn, _Args&&... __args);
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
  && (ATOMIC_INT_LOCK_FREE > 1)
  && (ATOMIC_INT_LOCK_FREE > 1)
  /// Base class and enclosing scope.
  /// Base class and enclosing scope.
  struct __future_base
  struct __future_base
  {
  {
    /// Base class for results.
    /// Base class for results.
    struct _Result_base
    struct _Result_base
    {
    {
      exception_ptr             _M_error;
      exception_ptr             _M_error;
      _Result_base(const _Result_base&) = delete;
      _Result_base(const _Result_base&) = delete;
      _Result_base& operator=(const _Result_base&) = delete;
      _Result_base& operator=(const _Result_base&) = delete;
      // _M_destroy() allows derived classes to control deallocation
      // _M_destroy() allows derived classes to control deallocation
      virtual void _M_destroy() = 0;
      virtual void _M_destroy() = 0;
      struct _Deleter
      struct _Deleter
      {
      {
        void operator()(_Result_base* __fr) const { __fr->_M_destroy(); }
        void operator()(_Result_base* __fr) const { __fr->_M_destroy(); }
      };
      };
    protected:
    protected:
      _Result_base();
      _Result_base();
      virtual ~_Result_base();
      virtual ~_Result_base();
    };
    };
    /// Result.
    /// Result.
    template
    template
      struct _Result : _Result_base
      struct _Result : _Result_base
      {
      {
      private:
      private:
        typedef alignment_of<_Res>                            __a_of;
        typedef alignment_of<_Res>                            __a_of;
        typedef aligned_storage __align_storage;
        typedef aligned_storage __align_storage;
        typedef typename __align_storage::type                  __align_type;
        typedef typename __align_storage::type                  __align_type;
        __align_type            _M_storage;
        __align_type            _M_storage;
        bool                    _M_initialized;
        bool                    _M_initialized;
      public:
      public:
        _Result() noexcept : _M_initialized() { }
        _Result() noexcept : _M_initialized() { }
        ~_Result()
        ~_Result()
        {
        {
          if (_M_initialized)
          if (_M_initialized)
            _M_value().~_Res();
            _M_value().~_Res();
        }
        }
        // Return lvalue, future will add const or rvalue-reference
        // Return lvalue, future will add const or rvalue-reference
        _Res&
        _Res&
        _M_value() noexcept { return *static_cast<_Res*>(_M_addr()); }
        _M_value() noexcept { return *static_cast<_Res*>(_M_addr()); }
        void
        void
        _M_set(const _Res& __res)
        _M_set(const _Res& __res)
        {
        {
          ::new (_M_addr()) _Res(__res);
          ::new (_M_addr()) _Res(__res);
          _M_initialized = true;
          _M_initialized = true;
        }
        }
        void
        void
        _M_set(_Res&& __res)
        _M_set(_Res&& __res)
        {
        {
          ::new (_M_addr()) _Res(std::move(__res));
          ::new (_M_addr()) _Res(std::move(__res));
          _M_initialized = true;
          _M_initialized = true;
        }
        }
      private:
      private:
        void _M_destroy() { delete this; }
        void _M_destroy() { delete this; }
        void* _M_addr() noexcept { return static_cast(&_M_storage); }
        void* _M_addr() noexcept { return static_cast(&_M_storage); }
    };
    };
    /// A unique_ptr based on the instantiating type.
    /// A unique_ptr based on the instantiating type.
    template
    template
      using _Ptr = unique_ptr<_Res, _Result_base::_Deleter>;
      using _Ptr = unique_ptr<_Res, _Result_base::_Deleter>;
    /// Result_alloc.
    /// Result_alloc.
    template
    template
      struct _Result_alloc final : _Result<_Res>, _Alloc
      struct _Result_alloc final : _Result<_Res>, _Alloc
      {
      {
        typedef typename allocator_traits<_Alloc>::template
        typedef typename allocator_traits<_Alloc>::template
          rebind_alloc<_Result_alloc> __allocator_type;
          rebind_alloc<_Result_alloc> __allocator_type;
        explicit
        explicit
        _Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a)
        _Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a)
        { }
        { }
      private:
      private:
        void _M_destroy()
        void _M_destroy()
        {
        {
          typedef allocator_traits<__allocator_type> __traits;
          typedef allocator_traits<__allocator_type> __traits;
          __allocator_type __a(*this);
          __allocator_type __a(*this);
          __traits::destroy(__a, this);
          __traits::destroy(__a, this);
          __traits::deallocate(__a, this, 1);
          __traits::deallocate(__a, this, 1);
        }
        }
      };
      };
    template
    template
      static _Ptr<_Result_alloc<_Res, _Allocator>>
      static _Ptr<_Result_alloc<_Res, _Allocator>>
      _S_allocate_result(const _Allocator& __a)
      _S_allocate_result(const _Allocator& __a)
      {
      {
        typedef _Result_alloc<_Res, _Allocator>   __result_type;
        typedef _Result_alloc<_Res, _Allocator>   __result_type;
        typedef allocator_traits
        typedef allocator_traits
          __traits;
          __traits;
        typename __traits::allocator_type __a2(__a);
        typename __traits::allocator_type __a2(__a);
        __result_type* __p = __traits::allocate(__a2, 1);
        __result_type* __p = __traits::allocate(__a2, 1);
        __try
        __try
        {
        {
          __traits::construct(__a2, __p, __a);
          __traits::construct(__a2, __p, __a);
        }
        }
        __catch(...)
        __catch(...)
        {
        {
          __traits::deallocate(__a2, __p, 1);
          __traits::deallocate(__a2, __p, 1);
          __throw_exception_again;
          __throw_exception_again;
        }
        }
        return _Ptr<__result_type>(__p);
        return _Ptr<__result_type>(__p);
      }
      }
    /// Base class for state between a promise and one or more
    /// Base class for state between a promise and one or more
    /// associated futures.
    /// associated futures.
    class _State_base
    class _State_base
    {
    {
      typedef _Ptr<_Result_base> _Ptr_type;
      typedef _Ptr<_Result_base> _Ptr_type;
      _Ptr_type                 _M_result;
      _Ptr_type                 _M_result;
      mutex                     _M_mutex;
      mutex                     _M_mutex;
      condition_variable        _M_cond;
      condition_variable        _M_cond;
      atomic_flag               _M_retrieved;
      atomic_flag               _M_retrieved;
      once_flag                 _M_once;
      once_flag                 _M_once;
    public:
    public:
      _State_base() noexcept : _M_result(), _M_retrieved(ATOMIC_FLAG_INIT) { }
      _State_base() noexcept : _M_result(), _M_retrieved(ATOMIC_FLAG_INIT) { }
      _State_base(const _State_base&) = delete;
      _State_base(const _State_base&) = delete;
      _State_base& operator=(const _State_base&) = delete;
      _State_base& operator=(const _State_base&) = delete;
      virtual ~_State_base();
      virtual ~_State_base();
      _Result_base&
      _Result_base&
      wait()
      wait()
      {
      {
        _M_run_deferred();
        _M_run_deferred();
        unique_lock __lock(_M_mutex);
        unique_lock __lock(_M_mutex);
        _M_cond.wait(__lock, [&] { return _M_ready(); });
        _M_cond.wait(__lock, [&] { return _M_ready(); });
        return *_M_result;
        return *_M_result;
      }
      }
      template
      template
        future_status
        future_status
        wait_for(const chrono::duration<_Rep, _Period>& __rel)
        wait_for(const chrono::duration<_Rep, _Period>& __rel)
        {
        {
          unique_lock __lock(_M_mutex);
          unique_lock __lock(_M_mutex);
          if (_M_cond.wait_for(__lock, __rel, [&] { return _M_ready(); }))
          if (_M_cond.wait_for(__lock, __rel, [&] { return _M_ready(); }))
            return future_status::ready;
            return future_status::ready;
          return future_status::timeout;
          return future_status::timeout;
        }
        }
      template
      template
        future_status
        future_status
        wait_until(const chrono::time_point<_Clock, _Duration>& __abs)
        wait_until(const chrono::time_point<_Clock, _Duration>& __abs)
        {
        {
          unique_lock __lock(_M_mutex);
          unique_lock __lock(_M_mutex);
          if (_M_cond.wait_until(__lock, __abs, [&] { return _M_ready(); }))
          if (_M_cond.wait_until(__lock, __abs, [&] { return _M_ready(); }))
            return future_status::ready;
            return future_status::ready;
          return future_status::timeout;
          return future_status::timeout;
        }
        }
      void
      void
      _M_set_result(function<_Ptr_type()> __res, bool __ignore_failure = false)
      _M_set_result(function<_Ptr_type()> __res, bool __ignore_failure = false)
      {
      {
        bool __set = __ignore_failure;
        bool __set = __ignore_failure;
        // all calls to this function are serialized,
        // all calls to this function are serialized,
        // side-effects of invoking __res only happen once
        // side-effects of invoking __res only happen once
        call_once(_M_once, &_State_base::_M_do_set, this, ref(__res),
        call_once(_M_once, &_State_base::_M_do_set, this, ref(__res),
            ref(__set));
            ref(__set));
        if (!__set)
        if (!__set)
          __throw_future_error(int(future_errc::promise_already_satisfied));
          __throw_future_error(int(future_errc::promise_already_satisfied));
      }
      }
      void
      void
      _M_break_promise(_Ptr_type __res)
      _M_break_promise(_Ptr_type __res)
      {
      {
        if (static_cast(__res))
        if (static_cast(__res))
          {
          {
            error_code __ec(make_error_code(future_errc::broken_promise));
            error_code __ec(make_error_code(future_errc::broken_promise));
            __res->_M_error = copy_exception(future_error(__ec));
            __res->_M_error = copy_exception(future_error(__ec));
            {
            {
              lock_guard __lock(_M_mutex);
              lock_guard __lock(_M_mutex);
              _M_result.swap(__res);
              _M_result.swap(__res);
            }
            }
            _M_cond.notify_all();
            _M_cond.notify_all();
          }
          }
      }
      }
      // Called when this object is passed to a future.
      // Called when this object is passed to a future.
      void
      void
      _M_set_retrieved_flag()
      _M_set_retrieved_flag()
      {
      {
        if (_M_retrieved.test_and_set())
        if (_M_retrieved.test_and_set())
          __throw_future_error(int(future_errc::future_already_retrieved));
          __throw_future_error(int(future_errc::future_already_retrieved));
      }
      }
      template
      template
        struct _Setter;
        struct _Setter;
      // set lvalues
      // set lvalues
      template
      template
        struct _Setter<_Res, _Arg&>
        struct _Setter<_Res, _Arg&>
        {
        {
          // check this is only used by promise::set_value(const R&)
          // check this is only used by promise::set_value(const R&)
          // or promise::set_value(R&)
          // or promise::set_value(R&)
          static_assert(is_same<_Res, _Arg&>::value  // promise
          static_assert(is_same<_Res, _Arg&>::value  // promise
              || is_same::value,  // promise
              || is_same::value,  // promise
              "Invalid specialisation");
              "Invalid specialisation");
          typename promise<_Res>::_Ptr_type operator()()
          typename promise<_Res>::_Ptr_type operator()()
          {
          {
            _State_base::_S_check(_M_promise->_M_future);
            _State_base::_S_check(_M_promise->_M_future);
            _M_promise->_M_storage->_M_set(_M_arg);
            _M_promise->_M_storage->_M_set(_M_arg);
            return std::move(_M_promise->_M_storage);
            return std::move(_M_promise->_M_storage);
          }
          }
          promise<_Res>*    _M_promise;
          promise<_Res>*    _M_promise;
          _Arg&             _M_arg;
          _Arg&             _M_arg;
        };
        };
      // set rvalues
      // set rvalues
      template
      template
        struct _Setter<_Res, _Res&&>
        struct _Setter<_Res, _Res&&>
        {
        {
          typename promise<_Res>::_Ptr_type operator()()
          typename promise<_Res>::_Ptr_type operator()()
          {
          {
            _State_base::_S_check(_M_promise->_M_future);
            _State_base::_S_check(_M_promise->_M_future);
            _M_promise->_M_storage->_M_set(std::move(_M_arg));
            _M_promise->_M_storage->_M_set(std::move(_M_arg));
            return std::move(_M_promise->_M_storage);
            return std::move(_M_promise->_M_storage);
          }
          }
          promise<_Res>*    _M_promise;
          promise<_Res>*    _M_promise;
          _Res&             _M_arg;
          _Res&             _M_arg;
        };
        };
      struct __exception_ptr_tag { };
      struct __exception_ptr_tag { };
      // set exceptions
      // set exceptions
      template
      template
        struct _Setter<_Res, __exception_ptr_tag>
        struct _Setter<_Res, __exception_ptr_tag>
        {
        {
          typename promise<_Res>::_Ptr_type operator()()
          typename promise<_Res>::_Ptr_type operator()()
          {
          {
            _State_base::_S_check(_M_promise->_M_future);
            _State_base::_S_check(_M_promise->_M_future);
            _M_promise->_M_storage->_M_error = _M_ex;
            _M_promise->_M_storage->_M_error = _M_ex;
            return std::move(_M_promise->_M_storage);
            return std::move(_M_promise->_M_storage);
          }
          }
          promise<_Res>*   _M_promise;
          promise<_Res>*   _M_promise;
          exception_ptr&    _M_ex;
          exception_ptr&    _M_ex;
        };
        };
      template
      template
        static _Setter<_Res, _Arg&&>
        static _Setter<_Res, _Arg&&>
        __setter(promise<_Res>* __prom, _Arg&& __arg)
        __setter(promise<_Res>* __prom, _Arg&& __arg)
        {
        {
          return _Setter<_Res, _Arg&&>{ __prom, __arg };
          return _Setter<_Res, _Arg&&>{ __prom, __arg };
        }
        }
      template
      template
        static _Setter<_Res, __exception_ptr_tag>
        static _Setter<_Res, __exception_ptr_tag>
        __setter(exception_ptr& __ex, promise<_Res>* __prom)
        __setter(exception_ptr& __ex, promise<_Res>* __prom)
        {
        {
          return _Setter<_Res, __exception_ptr_tag>{ __prom, __ex };
          return _Setter<_Res, __exception_ptr_tag>{ __prom, __ex };
        }
        }
      static _Setter
      static _Setter
      __setter(promise* __prom);
      __setter(promise* __prom);
      template
      template
        static bool
        static bool
        _S_check(const shared_ptr<_Tp>& __p)
        _S_check(const shared_ptr<_Tp>& __p)
        {
        {
          if (!static_cast(__p))
          if (!static_cast(__p))
            __throw_future_error((int)future_errc::no_state);
            __throw_future_error((int)future_errc::no_state);
        }
        }
    private:
    private:
      void
      void
      _M_do_set(function<_Ptr_type()>& __f, bool& __set)
      _M_do_set(function<_Ptr_type()>& __f, bool& __set)
      {
      {
        _Ptr_type __res = __f();
        _Ptr_type __res = __f();
        {
        {
          lock_guard __lock(_M_mutex);
          lock_guard __lock(_M_mutex);
          _M_result.swap(__res);
          _M_result.swap(__res);
        }
        }
        _M_cond.notify_all();
        _M_cond.notify_all();
        __set = true;
        __set = true;
      }
      }
      bool _M_ready() const noexcept { return static_cast(_M_result); }
      bool _M_ready() const noexcept { return static_cast(_M_result); }
      // Misnamed: waits for completion of async function.
      // Misnamed: waits for completion of async function.
      virtual void _M_run_deferred() { }
      virtual void _M_run_deferred() { }
    };
    };
    template
    template
      class _Deferred_state;
      class _Deferred_state;
    class _Async_state_common;
    class _Async_state_common;
    template
    template
      class _Async_state_impl;
      class _Async_state_impl;
    template
    template
      class _Task_state;
      class _Task_state;
    template
    template
      static std::shared_ptr<_State_base>
      static std::shared_ptr<_State_base>
      _S_make_deferred_state(_BoundFn&& __fn);
      _S_make_deferred_state(_BoundFn&& __fn);
    template
    template
      static std::shared_ptr<_State_base>
      static std::shared_ptr<_State_base>
      _S_make_async_state(_BoundFn&& __fn);
      _S_make_async_state(_BoundFn&& __fn);
    template
    template
      struct _Task_setter;
      struct _Task_setter;
    template
    template
      class _Task_setter_helper
      class _Task_setter_helper
      {
      {
        typedef typename remove_reference<_BoundFn>::type::result_type __res;
        typedef typename remove_reference<_BoundFn>::type::result_type __res;
      public:
      public:
        typedef _Task_setter<_Res_ptr, __res> __type;
        typedef _Task_setter<_Res_ptr, __res> __type;
      };
      };
    template
    template
      static typename _Task_setter_helper<_Res_ptr, _BoundFn>::__type
      static typename _Task_setter_helper<_Res_ptr, _BoundFn>::__type
      _S_task_setter(_Res_ptr& __ptr, _BoundFn&& __call)
      _S_task_setter(_Res_ptr& __ptr, _BoundFn&& __call)
      {
      {
        typedef _Task_setter_helper<_Res_ptr, _BoundFn> __helper_type;
        typedef _Task_setter_helper<_Res_ptr, _BoundFn> __helper_type;
        typedef typename __helper_type::__type _Setter;
        typedef typename __helper_type::__type _Setter;
        return _Setter{ __ptr, std::ref(__call) };
        return _Setter{ __ptr, std::ref(__call) };
      }
      }
  };
  };
  /// Partial specialization for reference types.
  /// Partial specialization for reference types.
  template
  template
    struct __future_base::_Result<_Res&> : __future_base::_Result_base
    struct __future_base::_Result<_Res&> : __future_base::_Result_base
    {
    {
      _Result() noexcept : _M_value_ptr() { }
      _Result() noexcept : _M_value_ptr() { }
      void _M_set(_Res& __res) noexcept { _M_value_ptr = &__res; }
      void _M_set(_Res& __res) noexcept { _M_value_ptr = &__res; }
      _Res& _M_get() noexcept { return *_M_value_ptr; }
      _Res& _M_get() noexcept { return *_M_value_ptr; }
    private:
    private:
      _Res*                     _M_value_ptr;
      _Res*                     _M_value_ptr;
      void _M_destroy() { delete this; }
      void _M_destroy() { delete this; }
    };
    };
  /// Explicit specialization for void.
  /// Explicit specialization for void.
  template<>
  template<>
    struct __future_base::_Result : __future_base::_Result_base
    struct __future_base::_Result : __future_base::_Result_base
    {
    {
    private:
    private:
      void _M_destroy() { delete this; }
      void _M_destroy() { delete this; }
    };
    };
  /// Common implementation for future and shared_future.
  /// Common implementation for future and shared_future.
  template
  template
    class __basic_future : public __future_base
    class __basic_future : public __future_base
    {
    {
    protected:
    protected:
      typedef shared_ptr<_State_base>                __state_type;
      typedef shared_ptr<_State_base>                __state_type;
      typedef __future_base::_Result<_Res>&	__result_type;
      typedef __future_base::_Result<_Res>&	__result_type;
    private:
    private:
      __state_type              _M_state;
      __state_type              _M_state;
    public:
    public:
      // Disable copying.
      // Disable copying.
      __basic_future(const __basic_future&) = delete;
      __basic_future(const __basic_future&) = delete;
      __basic_future& operator=(const __basic_future&) = delete;
      __basic_future& operator=(const __basic_future&) = delete;
      bool
      bool
      valid() const noexcept { return static_cast(_M_state); }
      valid() const noexcept { return static_cast(_M_state); }
      void
      void
      wait() const
      wait() const
      {
      {
        _State_base::_S_check(_M_state);
        _State_base::_S_check(_M_state);
        _M_state->wait();
        _M_state->wait();
      }
      }
      template
      template
        future_status
        future_status
        wait_for(const chrono::duration<_Rep, _Period>& __rel) const
        wait_for(const chrono::duration<_Rep, _Period>& __rel) const
        {
        {
          _State_base::_S_check(_M_state);
          _State_base::_S_check(_M_state);
          return _M_state->wait_for(__rel);
          return _M_state->wait_for(__rel);
        }
        }
      template
      template
        future_status
        future_status
        wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const
        wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const
        {
        {
          _State_base::_S_check(_M_state);
          _State_base::_S_check(_M_state);
          return _M_state->wait_until(__abs);
          return _M_state->wait_until(__abs);
        }
        }
    protected:
    protected:
      /// Wait for the state to be ready and rethrow any stored exception
      /// Wait for the state to be ready and rethrow any stored exception
      __result_type
      __result_type
      _M_get_result()
      _M_get_result()
      {
      {
        _State_base::_S_check(_M_state);
        _State_base::_S_check(_M_state);
        _Result_base& __res = _M_state->wait();
        _Result_base& __res = _M_state->wait();
        if (!(__res._M_error == 0))
        if (!(__res._M_error == 0))
          rethrow_exception(__res._M_error);
          rethrow_exception(__res._M_error);
        return static_cast<__result_type>(__res);
        return static_cast<__result_type>(__res);
      }
      }
      void _M_swap(__basic_future& __that) noexcept
      void _M_swap(__basic_future& __that) noexcept
      {
      {
        _M_state.swap(__that._M_state);
        _M_state.swap(__that._M_state);
      }
      }
      // Construction of a future by promise::get_future()
      // Construction of a future by promise::get_future()
      explicit
      explicit
      __basic_future(const __state_type& __state) : _M_state(__state)
      __basic_future(const __state_type& __state) : _M_state(__state)
      {
      {
        _State_base::_S_check(_M_state);
        _State_base::_S_check(_M_state);
        _M_state->_M_set_retrieved_flag();
        _M_state->_M_set_retrieved_flag();
      }
      }
      // Copy construction from a shared_future
      // Copy construction from a shared_future
      explicit
      explicit
      __basic_future(const shared_future<_Res>&) noexcept;
      __basic_future(const shared_future<_Res>&) noexcept;
      // Move construction from a shared_future
      // Move construction from a shared_future
      explicit
      explicit
      __basic_future(shared_future<_Res>&&) noexcept;
      __basic_future(shared_future<_Res>&&) noexcept;
      // Move construction from a future
      // Move construction from a future
      explicit
      explicit
      __basic_future(future<_Res>&&) noexcept;
      __basic_future(future<_Res>&&) noexcept;
      constexpr __basic_future() noexcept : _M_state() { }
      constexpr __basic_future() noexcept : _M_state() { }
      struct _Reset
      struct _Reset
      {
      {
        explicit _Reset(__basic_future& __fut) noexcept : _M_fut(__fut) { }
        explicit _Reset(__basic_future& __fut) noexcept : _M_fut(__fut) { }
        ~_Reset() { _M_fut._M_state.reset(); }
        ~_Reset() { _M_fut._M_state.reset(); }
        __basic_future& _M_fut;
        __basic_future& _M_fut;
      };
      };
    };
    };
  /// Primary template for future.
  /// Primary template for future.
  template
  template
    class future : public __basic_future<_Res>
    class future : public __basic_future<_Res>
    {
    {
      friend class promise<_Res>;
      friend class promise<_Res>;
      template friend class packaged_task;
      template friend class packaged_task;
      template
      template
        friend future::type>
        friend future::type>
        async(launch, _Fn&&, _Args&&...);
        async(launch, _Fn&&, _Args&&...);
      typedef __basic_future<_Res> _Base_type;
      typedef __basic_future<_Res> _Base_type;
      typedef typename _Base_type::__state_type __state_type;
      typedef typename _Base_type::__state_type __state_type;
      explicit
      explicit
      future(const __state_type& __state) : _Base_type(__state) { }
      future(const __state_type& __state) : _Base_type(__state) { }
    public:
    public:
      constexpr future() noexcept : _Base_type() { }
      constexpr future() noexcept : _Base_type() { }
      /// Move constructor
      /// Move constructor
      future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
      future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
      // Disable copying
      // Disable copying
      future(const future&) = delete;
      future(const future&) = delete;
      future& operator=(const future&) = delete;
      future& operator=(const future&) = delete;
      future& operator=(future&& __fut) noexcept
      future& operator=(future&& __fut) noexcept
      {
      {
        future(std::move(__fut))._M_swap(*this);
        future(std::move(__fut))._M_swap(*this);
        return *this;
        return *this;
      }
      }
      /// Retrieving the value
      /// Retrieving the value
      _Res
      _Res
      get()
      get()
      {
      {
        typename _Base_type::_Reset __reset(*this);
        typename _Base_type::_Reset __reset(*this);
        return std::move(this->_M_get_result()._M_value());
        return std::move(this->_M_get_result()._M_value());
      }
      }
      shared_future<_Res> share();
      shared_future<_Res> share();
    };
    };
  /// Partial specialization for future
  /// Partial specialization for future
  template
  template
    class future<_Res&> : public __basic_future<_Res&>
    class future<_Res&> : public __basic_future<_Res&>
    {
    {
      friend class promise<_Res&>;
      friend class promise<_Res&>;
      template friend class packaged_task;
      template friend class packaged_task;
      template
      template
        friend future::type>
        friend future::type>
        async(launch, _Fn&&, _Args&&...);
        async(launch, _Fn&&, _Args&&...);
      typedef __basic_future<_Res&> _Base_type;
      typedef __basic_future<_Res&> _Base_type;
      typedef typename _Base_type::__state_type __state_type;
      typedef typename _Base_type::__state_type __state_type;
      explicit
      explicit
      future(const __state_type& __state) : _Base_type(__state) { }
      future(const __state_type& __state) : _Base_type(__state) { }
    public:
    public:
      constexpr future() noexcept : _Base_type() { }
      constexpr future() noexcept : _Base_type() { }
      /// Move constructor
      /// Move constructor
      future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
      future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
      // Disable copying
      // Disable copying
      future(const future&) = delete;
      future(const future&) = delete;
      future& operator=(const future&) = delete;
      future& operator=(const future&) = delete;
      future& operator=(future&& __fut) noexcept
      future& operator=(future&& __fut) noexcept
      {
      {
        future(std::move(__fut))._M_swap(*this);
        future(std::move(__fut))._M_swap(*this);
        return *this;
        return *this;
      }
      }
      /// Retrieving the value
      /// Retrieving the value
      _Res&
      _Res&
      get()
      get()
      {
      {
        typename _Base_type::_Reset __reset(*this);
        typename _Base_type::_Reset __reset(*this);
        return this->_M_get_result()._M_get();
        return this->_M_get_result()._M_get();
      }
      }
      shared_future<_Res&> share();
      shared_future<_Res&> share();
    };
    };
  /// Explicit specialization for future
  /// Explicit specialization for future
  template<>
  template<>
    class future : public __basic_future
    class future : public __basic_future
    {
    {
      friend class promise;
      friend class promise;
      template friend class packaged_task;
      template friend class packaged_task;
      template
      template
        friend future::type>
        friend future::type>
        async(launch, _Fn&&, _Args&&...);
        async(launch, _Fn&&, _Args&&...);
      typedef __basic_future _Base_type;
      typedef __basic_future _Base_type;
      typedef typename _Base_type::__state_type __state_type;
      typedef typename _Base_type::__state_type __state_type;
      explicit
      explicit
      future(const __state_type& __state) : _Base_type(__state) { }
      future(const __state_type& __state) : _Base_type(__state) { }
    public:
    public:
      constexpr future() noexcept : _Base_type() { }
      constexpr future() noexcept : _Base_type() { }
      /// Move constructor
      /// Move constructor
      future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
      future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
      // Disable copying
      // Disable copying
      future(const future&) = delete;
      future(const future&) = delete;
      future& operator=(const future&) = delete;
      future& operator=(const future&) = delete;
      future& operator=(future&& __fut) noexcept
      future& operator=(future&& __fut) noexcept
      {
      {
        future(std::move(__fut))._M_swap(*this);
        future(std::move(__fut))._M_swap(*this);
        return *this;
        return *this;
      }
      }
      /// Retrieving the value
      /// Retrieving the value
      void
      void
      get()
      get()
      {
      {
        typename _Base_type::_Reset __reset(*this);
        typename _Base_type::_Reset __reset(*this);
        this->_M_get_result();
        this->_M_get_result();
      }
      }
      shared_future share();
      shared_future share();
    };
    };
  /// Primary template for shared_future.
  /// Primary template for shared_future.
  template
  template
    class shared_future : public __basic_future<_Res>
    class shared_future : public __basic_future<_Res>
    {
    {
      typedef __basic_future<_Res> _Base_type;
      typedef __basic_future<_Res> _Base_type;
    public:
    public:
      constexpr shared_future() noexcept : _Base_type() { }
      constexpr shared_future() noexcept : _Base_type() { }
      /// Copy constructor
      /// Copy constructor
      shared_future(const shared_future& __sf) : _Base_type(__sf) { }
      shared_future(const shared_future& __sf) : _Base_type(__sf) { }
      /// Construct from a future rvalue
      /// Construct from a future rvalue
      shared_future(future<_Res>&& __uf) noexcept
      shared_future(future<_Res>&& __uf) noexcept
      : _Base_type(std::move(__uf))
      : _Base_type(std::move(__uf))
      { }
      { }
      /// Construct from a shared_future rvalue
      /// Construct from a shared_future rvalue
      shared_future(shared_future&& __sf) noexcept
      shared_future(shared_future&& __sf) noexcept
      : _Base_type(std::move(__sf))
      : _Base_type(std::move(__sf))
      { }
      { }
      shared_future& operator=(const shared_future& __sf)
      shared_future& operator=(const shared_future& __sf)
      {
      {
        shared_future(__sf)._M_swap(*this);
        shared_future(__sf)._M_swap(*this);
        return *this;
        return *this;
      }
      }
      shared_future& operator=(shared_future&& __sf) noexcept
      shared_future& operator=(shared_future&& __sf) noexcept
      {
      {
        shared_future(std::move(__sf))._M_swap(*this);
        shared_future(std::move(__sf))._M_swap(*this);
        return *this;
        return *this;
      }
      }
      /// Retrieving the value
      /// Retrieving the value
      const _Res&
      const _Res&
      get()
      get()
      {
      {
        typename _Base_type::__result_type __r = this->_M_get_result();
        typename _Base_type::__result_type __r = this->_M_get_result();
        _Res& __rs(__r._M_value());
        _Res& __rs(__r._M_value());
        return __rs;
        return __rs;
      }
      }
    };
    };
  /// Partial specialization for shared_future
  /// Partial specialization for shared_future
  template
  template
    class shared_future<_Res&> : public __basic_future<_Res&>
    class shared_future<_Res&> : public __basic_future<_Res&>
    {
    {
      typedef __basic_future<_Res&>           _Base_type;
      typedef __basic_future<_Res&>           _Base_type;
    public:
    public:
      constexpr shared_future() noexcept : _Base_type() { }
      constexpr shared_future() noexcept : _Base_type() { }
      /// Copy constructor
      /// Copy constructor
      shared_future(const shared_future& __sf) : _Base_type(__sf) { }
      shared_future(const shared_future& __sf) : _Base_type(__sf) { }
      /// Construct from a future rvalue
      /// Construct from a future rvalue
      shared_future(future<_Res&>&& __uf) noexcept
      shared_future(future<_Res&>&& __uf) noexcept
      : _Base_type(std::move(__uf))
      : _Base_type(std::move(__uf))
      { }
      { }
      /// Construct from a shared_future rvalue
      /// Construct from a shared_future rvalue
      shared_future(shared_future&& __sf) noexcept
      shared_future(shared_future&& __sf) noexcept
      : _Base_type(std::move(__sf))
      : _Base_type(std::move(__sf))
      { }
      { }
      shared_future& operator=(const shared_future& __sf)
      shared_future& operator=(const shared_future& __sf)
      {
      {
        shared_future(__sf)._M_swap(*this);
        shared_future(__sf)._M_swap(*this);
        return *this;
        return *this;
      }
      }
      shared_future& operator=(shared_future&& __sf) noexcept
      shared_future& operator=(shared_future&& __sf) noexcept
      {
      {
        shared_future(std::move(__sf))._M_swap(*this);
        shared_future(std::move(__sf))._M_swap(*this);
        return *this;
        return *this;
      }
      }
      /// Retrieving the value
      /// Retrieving the value
      _Res&
      _Res&
      get() { return this->_M_get_result()._M_get(); }
      get() { return this->_M_get_result()._M_get(); }
    };
    };
  /// Explicit specialization for shared_future
  /// Explicit specialization for shared_future
  template<>
  template<>
    class shared_future : public __basic_future
    class shared_future : public __basic_future
    {
    {
      typedef __basic_future _Base_type;
      typedef __basic_future _Base_type;
    public:
    public:
      constexpr shared_future() noexcept : _Base_type() { }
      constexpr shared_future() noexcept : _Base_type() { }
      /// Copy constructor
      /// Copy constructor
      shared_future(const shared_future& __sf) : _Base_type(__sf) { }
      shared_future(const shared_future& __sf) : _Base_type(__sf) { }
      /// Construct from a future rvalue
      /// Construct from a future rvalue
      shared_future(future&& __uf) noexcept
      shared_future(future&& __uf) noexcept
      : _Base_type(std::move(__uf))
      : _Base_type(std::move(__uf))
      { }
      { }
      /// Construct from a shared_future rvalue
      /// Construct from a shared_future rvalue
      shared_future(shared_future&& __sf) noexcept
      shared_future(shared_future&& __sf) noexcept
      : _Base_type(std::move(__sf))
      : _Base_type(std::move(__sf))
      { }
      { }
      shared_future& operator=(const shared_future& __sf)
      shared_future& operator=(const shared_future& __sf)
      {
      {
        shared_future(__sf)._M_swap(*this);
        shared_future(__sf)._M_swap(*this);
        return *this;
        return *this;
      }
      }
      shared_future& operator=(shared_future&& __sf) noexcept
      shared_future& operator=(shared_future&& __sf) noexcept
      {
      {
        shared_future(std::move(__sf))._M_swap(*this);
        shared_future(std::move(__sf))._M_swap(*this);
        return *this;
        return *this;
      }
      }
      // Retrieving the value
      // Retrieving the value
      void
      void
      get() { this->_M_get_result(); }
      get() { this->_M_get_result(); }
    };
    };
  // Now we can define the protected __basic_future constructors.
  // Now we can define the protected __basic_future constructors.
  template
  template
    inline __basic_future<_Res>::
    inline __basic_future<_Res>::
    __basic_future(const shared_future<_Res>& __sf) noexcept
    __basic_future(const shared_future<_Res>& __sf) noexcept
    : _M_state(__sf._M_state)
    : _M_state(__sf._M_state)
    { }
    { }
  template
  template
    inline __basic_future<_Res>::
    inline __basic_future<_Res>::
    __basic_future(shared_future<_Res>&& __sf) noexcept
    __basic_future(shared_future<_Res>&& __sf) noexcept
    : _M_state(std::move(__sf._M_state))
    : _M_state(std::move(__sf._M_state))
    { }
    { }
  template
  template
    inline __basic_future<_Res>::
    inline __basic_future<_Res>::
    __basic_future(future<_Res>&& __uf) noexcept
    __basic_future(future<_Res>&& __uf) noexcept
    : _M_state(std::move(__uf._M_state))
    : _M_state(std::move(__uf._M_state))
    { }
    { }
  template
  template
    inline shared_future<_Res>
    inline shared_future<_Res>
    future<_Res>::share()
    future<_Res>::share()
    { return shared_future<_Res>(std::move(*this)); }
    { return shared_future<_Res>(std::move(*this)); }
  template
  template
    inline shared_future<_Res&>
    inline shared_future<_Res&>
    future<_Res&>::share()
    future<_Res&>::share()
    { return shared_future<_Res&>(std::move(*this)); }
    { return shared_future<_Res&>(std::move(*this)); }
  inline shared_future
  inline shared_future
  future::share()
  future::share()
  { return shared_future(std::move(*this)); }
  { return shared_future(std::move(*this)); }
  /// Primary template for promise
  /// Primary template for promise
  template
  template
    class promise
    class promise
    {
    {
      typedef __future_base::_State_base        _State;
      typedef __future_base::_State_base        _State;
      typedef __future_base::_Result<_Res>    _Res_type;
      typedef __future_base::_Result<_Res>    _Res_type;
      typedef __future_base::_Ptr<_Res_type>       _Ptr_type;
      typedef __future_base::_Ptr<_Res_type>       _Ptr_type;
      template friend class _State::_Setter;
      template friend class _State::_Setter;
      shared_ptr<_State>                        _M_future;
      shared_ptr<_State>                        _M_future;
      _Ptr_type                                 _M_storage;
      _Ptr_type                                 _M_storage;
    public:
    public:
      promise()
      promise()
      : _M_future(std::make_shared<_State>()),
      : _M_future(std::make_shared<_State>()),
        _M_storage(new _Res_type())
        _M_storage(new _Res_type())
      { }
      { }
      promise(promise&& __rhs) noexcept
      promise(promise&& __rhs) noexcept
      : _M_future(std::move(__rhs._M_future)),
      : _M_future(std::move(__rhs._M_future)),
        _M_storage(std::move(__rhs._M_storage))
        _M_storage(std::move(__rhs._M_storage))
      { }
      { }
      template
      template
        promise(allocator_arg_t, const _Allocator& __a)
        promise(allocator_arg_t, const _Allocator& __a)
        : _M_future(std::allocate_shared<_State>(__a)),
        : _M_future(std::allocate_shared<_State>(__a)),
          _M_storage(__future_base::_S_allocate_result<_Res>(__a))
          _M_storage(__future_base::_S_allocate_result<_Res>(__a))
        { }
        { }
      template
      template
        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
        : _M_future(std::move(__rhs._M_future)),
        : _M_future(std::move(__rhs._M_future)),
          _M_storage(std::move(__rhs._M_storage))
          _M_storage(std::move(__rhs._M_storage))
        { }
        { }
      promise(const promise&) = delete;
      promise(const promise&) = delete;
      ~promise()
      ~promise()
      {
      {
        if (static_cast(_M_future) && !_M_future.unique())
        if (static_cast(_M_future) && !_M_future.unique())
          _M_future->_M_break_promise(std::move(_M_storage));
          _M_future->_M_break_promise(std::move(_M_storage));
      }
      }
      // Assignment
      // Assignment
      promise&
      promise&
      operator=(promise&& __rhs) noexcept
      operator=(promise&& __rhs) noexcept
      {
      {
        promise(std::move(__rhs)).swap(*this);
        promise(std::move(__rhs)).swap(*this);
        return *this;
        return *this;
      }
      }
      promise& operator=(const promise&) = delete;
      promise& operator=(const promise&) = delete;
      void
      void
      swap(promise& __rhs) noexcept
      swap(promise& __rhs) noexcept
      {
      {
        _M_future.swap(__rhs._M_future);
        _M_future.swap(__rhs._M_future);
        _M_storage.swap(__rhs._M_storage);
        _M_storage.swap(__rhs._M_storage);
      }
      }
      // Retrieving the result
      // Retrieving the result
      future<_Res>
      future<_Res>
      get_future()
      get_future()
      { return future<_Res>(_M_future); }
      { return future<_Res>(_M_future); }
      // Setting the result
      // Setting the result
      void
      void
      set_value(const _Res& __r)
      set_value(const _Res& __r)
      {
      {
        auto __setter = _State::__setter(this, __r);
        auto __setter = _State::__setter(this, __r);
        _M_future->_M_set_result(std::move(__setter));
        _M_future->_M_set_result(std::move(__setter));
      }
      }
      void
      void
      set_value(_Res&& __r)
      set_value(_Res&& __r)
      {
      {
        auto __setter = _State::__setter(this, std::move(__r));
        auto __setter = _State::__setter(this, std::move(__r));
        _M_future->_M_set_result(std::move(__setter));
        _M_future->_M_set_result(std::move(__setter));
      }
      }
      void
      void
      set_exception(exception_ptr __p)
      set_exception(exception_ptr __p)
      {
      {
        auto __setter = _State::__setter(__p, this);
        auto __setter = _State::__setter(__p, this);
        _M_future->_M_set_result(std::move(__setter));
        _M_future->_M_set_result(std::move(__setter));
      }
      }
    };
    };
  template
  template
    inline void
    inline void
    swap(promise<_Res>& __x, promise<_Res>& __y) noexcept
    swap(promise<_Res>& __x, promise<_Res>& __y) noexcept
    { __x.swap(__y); }
    { __x.swap(__y); }
  template
  template
    struct uses_allocator, _Alloc>
    struct uses_allocator, _Alloc>
    : public true_type { };
    : public true_type { };
  /// Partial specialization for promise
  /// Partial specialization for promise
  template
  template
    class promise<_Res&>
    class promise<_Res&>
    {
    {
      typedef __future_base::_State_base        _State;
      typedef __future_base::_State_base        _State;
      typedef __future_base::_Result<_Res&>    _Res_type;
      typedef __future_base::_Result<_Res&>    _Res_type;
      typedef __future_base::_Ptr<_Res_type>       _Ptr_type;
      typedef __future_base::_Ptr<_Res_type>       _Ptr_type;
      template friend class _State::_Setter;
      template friend class _State::_Setter;
      shared_ptr<_State>                        _M_future;
      shared_ptr<_State>                        _M_future;
      _Ptr_type                                 _M_storage;
      _Ptr_type                                 _M_storage;
    public:
    public:
      promise()
      promise()
      : _M_future(std::make_shared<_State>()),
      : _M_future(std::make_shared<_State>()),
        _M_storage(new _Res_type())
        _M_storage(new _Res_type())
      { }
      { }
      promise(promise&& __rhs) noexcept
      promise(promise&& __rhs) noexcept
      : _M_future(std::move(__rhs._M_future)),
      : _M_future(std::move(__rhs._M_future)),
        _M_storage(std::move(__rhs._M_storage))
        _M_storage(std::move(__rhs._M_storage))
      { }
      { }
      template
      template
        promise(allocator_arg_t, const _Allocator& __a)
        promise(allocator_arg_t, const _Allocator& __a)
        : _M_future(std::allocate_shared<_State>(__a)),
        : _M_future(std::allocate_shared<_State>(__a)),
          _M_storage(__future_base::_S_allocate_result<_Res&>(__a))
          _M_storage(__future_base::_S_allocate_result<_Res&>(__a))
        { }
        { }
      template
      template
        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
        : _M_future(std::move(__rhs._M_future)),
        : _M_future(std::move(__rhs._M_future)),
          _M_storage(std::move(__rhs._M_storage))
          _M_storage(std::move(__rhs._M_storage))
        { }
        { }
      promise(const promise&) = delete;
      promise(const promise&) = delete;
      ~promise()
      ~promise()
      {
      {
        if (static_cast(_M_future) && !_M_future.unique())
        if (static_cast(_M_future) && !_M_future.unique())
          _M_future->_M_break_promise(std::move(_M_storage));
          _M_future->_M_break_promise(std::move(_M_storage));
      }
      }
      // Assignment
      // Assignment
      promise&
      promise&
      operator=(promise&& __rhs) noexcept
      operator=(promise&& __rhs) noexcept
      {
      {
        promise(std::move(__rhs)).swap(*this);
        promise(std::move(__rhs)).swap(*this);
        return *this;
        return *this;
      }
      }
      promise& operator=(const promise&) = delete;
      promise& operator=(const promise&) = delete;
      void
      void
      swap(promise& __rhs) noexcept
      swap(promise& __rhs) noexcept
      {
      {
        _M_future.swap(__rhs._M_future);
        _M_future.swap(__rhs._M_future);
        _M_storage.swap(__rhs._M_storage);
        _M_storage.swap(__rhs._M_storage);
      }
      }
      // Retrieving the result
      // Retrieving the result
      future<_Res&>
      future<_Res&>
      get_future()
      get_future()
      { return future<_Res&>(_M_future); }
      { return future<_Res&>(_M_future); }
      // Setting the result
      // Setting the result
      void
      void
      set_value(_Res& __r)
      set_value(_Res& __r)
      {
      {
        auto __setter = _State::__setter(this, __r);
        auto __setter = _State::__setter(this, __r);
        _M_future->_M_set_result(std::move(__setter));
        _M_future->_M_set_result(std::move(__setter));
      }
      }
      void
      void
      set_exception(exception_ptr __p)
      set_exception(exception_ptr __p)
      {
      {
        auto __setter = _State::__setter(__p, this);
        auto __setter = _State::__setter(__p, this);
        _M_future->_M_set_result(std::move(__setter));
        _M_future->_M_set_result(std::move(__setter));
      }
      }
    };
    };
  /// Explicit specialization for promise
  /// Explicit specialization for promise
  template<>
  template<>
    class promise
    class promise
    {
    {
      typedef __future_base::_State_base        _State;
      typedef __future_base::_State_base        _State;
      typedef __future_base::_Result    _Res_type;
      typedef __future_base::_Result    _Res_type;
      typedef __future_base::_Ptr<_Res_type>       _Ptr_type;
      typedef __future_base::_Ptr<_Res_type>       _Ptr_type;
      template friend class _State::_Setter;
      template friend class _State::_Setter;
      shared_ptr<_State>                        _M_future;
      shared_ptr<_State>                        _M_future;
      _Ptr_type                                 _M_storage;
      _Ptr_type                                 _M_storage;
    public:
    public:
      promise()
      promise()
      : _M_future(std::make_shared<_State>()),
      : _M_future(std::make_shared<_State>()),
        _M_storage(new _Res_type())
        _M_storage(new _Res_type())
      { }
      { }
      promise(promise&& __rhs) noexcept
      promise(promise&& __rhs) noexcept
      : _M_future(std::move(__rhs._M_future)),
      : _M_future(std::move(__rhs._M_future)),
        _M_storage(std::move(__rhs._M_storage))
        _M_storage(std::move(__rhs._M_storage))
      { }
      { }
      template
      template
        promise(allocator_arg_t, const _Allocator& __a)
        promise(allocator_arg_t, const _Allocator& __a)
        : _M_future(std::allocate_shared<_State>(__a)),
        : _M_future(std::allocate_shared<_State>(__a)),
          _M_storage(__future_base::_S_allocate_result(__a))
          _M_storage(__future_base::_S_allocate_result(__a))
        { }
        { }
      template
      template
        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
        promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
        : _M_future(std::move(__rhs._M_future)),
        : _M_future(std::move(__rhs._M_future)),
          _M_storage(std::move(__rhs._M_storage))
          _M_storage(std::move(__rhs._M_storage))
        { }
        { }
      promise(const promise&) = delete;
      promise(const promise&) = delete;
      ~promise()
      ~promise()
      {
      {
        if (static_cast(_M_future) && !_M_future.unique())
        if (static_cast(_M_future) && !_M_future.unique())
          _M_future->_M_break_promise(std::move(_M_storage));
          _M_future->_M_break_promise(std::move(_M_storage));
      }
      }
      // Assignment
      // Assignment
      promise&
      promise&
      operator=(promise&& __rhs) noexcept
      operator=(promise&& __rhs) noexcept
      {
      {
        promise(std::move(__rhs)).swap(*this);
        promise(std::move(__rhs)).swap(*this);
        return *this;
        return *this;
      }
      }
      promise& operator=(const promise&) = delete;
      promise& operator=(const promise&) = delete;
      void
      void
      swap(promise& __rhs) noexcept
      swap(promise& __rhs) noexcept
      {
      {
        _M_future.swap(__rhs._M_future);
        _M_future.swap(__rhs._M_future);
        _M_storage.swap(__rhs._M_storage);
        _M_storage.swap(__rhs._M_storage);
      }
      }
      // Retrieving the result
      // Retrieving the result
      future
      future
      get_future()
      get_future()
      { return future(_M_future); }
      { return future(_M_future); }
      // Setting the result
      // Setting the result
      void set_value();
      void set_value();
      void
      void
      set_exception(exception_ptr __p)
      set_exception(exception_ptr __p)
      {
      {
        auto __setter = _State::__setter(__p, this);
        auto __setter = _State::__setter(__p, this);
        _M_future->_M_set_result(std::move(__setter));
        _M_future->_M_set_result(std::move(__setter));
      }
      }
    };
    };
  // set void
  // set void
  template<>
  template<>
    struct __future_base::_State_base::_Setter
    struct __future_base::_State_base::_Setter
    {
    {
      promise::_Ptr_type operator()()
      promise::_Ptr_type operator()()
      {
      {
        _State_base::_S_check(_M_promise->_M_future);
        _State_base::_S_check(_M_promise->_M_future);
        return std::move(_M_promise->_M_storage);
        return std::move(_M_promise->_M_storage);
      }
      }
      promise*    _M_promise;
      promise*    _M_promise;
    };
    };
  inline __future_base::_State_base::_Setter
  inline __future_base::_State_base::_Setter
  __future_base::_State_base::__setter(promise* __prom)
  __future_base::_State_base::__setter(promise* __prom)
  {
  {
    return _Setter{ __prom };
    return _Setter{ __prom };
  }
  }
  inline void
  inline void
  promise::set_value()
  promise::set_value()
  {
  {
    auto __setter = _State::__setter(this);
    auto __setter = _State::__setter(this);
    _M_future->_M_set_result(std::move(__setter));
    _M_future->_M_set_result(std::move(__setter));
  }
  }
  template
  template
    struct __future_base::_Task_setter
    struct __future_base::_Task_setter
    {
    {
      _Ptr_type operator()()
      _Ptr_type operator()()
      {
      {
        __try
        __try
          {
          {
            _M_result->_M_set(_M_fn());
            _M_result->_M_set(_M_fn());
          }
          }
        __catch(...)
        __catch(...)
          {
          {
            _M_result->_M_error = current_exception();
            _M_result->_M_error = current_exception();
          }
          }
        return std::move(_M_result);
        return std::move(_M_result);
      }
      }
      _Ptr_type&                _M_result;
      _Ptr_type&                _M_result;
      std::function<_Res()>     _M_fn;
      std::function<_Res()>     _M_fn;
    };
    };
  template
  template
    struct __future_base::_Task_setter<_Ptr_type, void>
    struct __future_base::_Task_setter<_Ptr_type, void>
    {
    {
      _Ptr_type operator()()
      _Ptr_type operator()()
      {
      {
        __try
        __try
          {
          {
            _M_fn();
            _M_fn();
          }
          }
        __catch(...)
        __catch(...)
          {
          {
            _M_result->_M_error = current_exception();
            _M_result->_M_error = current_exception();
          }
          }
        return std::move(_M_result);
        return std::move(_M_result);
      }
      }
      _Ptr_type&                _M_result;
      _Ptr_type&                _M_result;
      std::function     _M_fn;
      std::function     _M_fn;
    };
    };
  template
  template
    struct __future_base::_Task_state<_Res(_Args...)> final
    struct __future_base::_Task_state<_Res(_Args...)> final
    : __future_base::_State_base
    : __future_base::_State_base
    {
    {
      typedef _Res _Res_type;
      typedef _Res _Res_type;
      _Task_state(std::function<_Res(_Args...)> __task)
      _Task_state(std::function<_Res(_Args...)> __task)
      : _M_result(new _Result<_Res>()), _M_task(std::move(__task))
      : _M_result(new _Result<_Res>()), _M_task(std::move(__task))
      { }
      { }
      template
      template
        _Task_state(_Func&& __task, const _Alloc& __a)
        _Task_state(_Func&& __task, const _Alloc& __a)
        : _M_result(_S_allocate_result<_Res>(__a)),
        : _M_result(_S_allocate_result<_Res>(__a)),
          _M_task(allocator_arg, __a, std::move(__task))
          _M_task(allocator_arg, __a, std::move(__task))
        { }
        { }
      void
      void
      _M_run(_Args... __args)
      _M_run(_Args... __args)
      {
      {
        // bound arguments decay so wrap lvalue references
        // bound arguments decay so wrap lvalue references
        auto __boundfn = std::__bind_simple(std::ref(_M_task),
        auto __boundfn = std::__bind_simple(std::ref(_M_task),
            _S_maybe_wrap_ref(std::forward<_Args>(__args))...);
            _S_maybe_wrap_ref(std::forward<_Args>(__args))...);
        auto __setter = _S_task_setter(_M_result, std::move(__boundfn));
        auto __setter = _S_task_setter(_M_result, std::move(__boundfn));
        _M_set_result(std::move(__setter));
        _M_set_result(std::move(__setter));
      }
      }
      typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
      typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
      _Ptr_type _M_result;
      _Ptr_type _M_result;
      std::function<_Res(_Args...)> _M_task;
      std::function<_Res(_Args...)> _M_task;
      template
      template
        static reference_wrapper<_Tp>
        static reference_wrapper<_Tp>
        _S_maybe_wrap_ref(_Tp& __t)
        _S_maybe_wrap_ref(_Tp& __t)
        { return std::ref(__t); }
        { return std::ref(__t); }
      template
      template
        static typename enable_if::value,
        static typename enable_if::value,
                        _Tp>::type&&
                        _Tp>::type&&
        _S_maybe_wrap_ref(_Tp&& __t)
        _S_maybe_wrap_ref(_Tp&& __t)
        { return std::forward<_Tp>(__t); }
        { return std::forward<_Tp>(__t); }
    };
    };
  template
  template
           = is_same<_Task, typename decay<_Fn>::type>::value>
           = is_same<_Task, typename decay<_Fn>::type>::value>
    struct __constrain_pkgdtask
    struct __constrain_pkgdtask
    { typedef void __type; };
    { typedef void __type; };
  template
  template
    struct __constrain_pkgdtask<_Task, _Fn, true>
    struct __constrain_pkgdtask<_Task, _Fn, true>
    { };
    { };
  /// packaged_task
  /// packaged_task
  template
  template
    class packaged_task<_Res(_ArgTypes...)>
    class packaged_task<_Res(_ArgTypes...)>
    {
    {
      typedef __future_base::_Task_state<_Res(_ArgTypes...)>  _State_type;
      typedef __future_base::_Task_state<_Res(_ArgTypes...)>  _State_type;
      shared_ptr<_State_type>                   _M_state;
      shared_ptr<_State_type>                   _M_state;
    public:
    public:
      // Construction and destruction
      // Construction and destruction
      packaged_task() noexcept { }
      packaged_task() noexcept { }
      template
      template
        explicit
        explicit
        packaged_task(allocator_arg_t, const _Allocator& __a) noexcept
        packaged_task(allocator_arg_t, const _Allocator& __a) noexcept
        { }
        { }
      template
      template
               __constrain_pkgdtask::__type>
               __constrain_pkgdtask::__type>
        explicit
        explicit
        packaged_task(_Fn&& __fn)
        packaged_task(_Fn&& __fn)
        : _M_state(std::make_shared<_State_type>(std::forward<_Fn>(__fn)))
        : _M_state(std::make_shared<_State_type>(std::forward<_Fn>(__fn)))
        { }
        { }
      template
      template
               __constrain_pkgdtask::__type>
               __constrain_pkgdtask::__type>
        explicit
        explicit
        packaged_task(allocator_arg_t, const _Allocator& __a, _Fn&& __fn)
        packaged_task(allocator_arg_t, const _Allocator& __a, _Fn&& __fn)
        : _M_state(std::allocate_shared<_State_type>(__a,
        : _M_state(std::allocate_shared<_State_type>(__a,
                                                     std::forward<_Fn>(__fn)))
                                                     std::forward<_Fn>(__fn)))
        { }
        { }
      ~packaged_task()
      ~packaged_task()
      {
      {
        if (static_cast(_M_state) && !_M_state.unique())
        if (static_cast(_M_state) && !_M_state.unique())
          _M_state->_M_break_promise(std::move(_M_state->_M_result));
          _M_state->_M_break_promise(std::move(_M_state->_M_result));
      }
      }
      // No copy
      // No copy
      packaged_task(const packaged_task&) = delete;
      packaged_task(const packaged_task&) = delete;
      packaged_task& operator=(const packaged_task&) = delete;
      packaged_task& operator=(const packaged_task&) = delete;
      template
      template
        explicit
        explicit
        packaged_task(allocator_arg_t, const _Allocator&,
        packaged_task(allocator_arg_t, const _Allocator&,
                      const packaged_task&) = delete;
                      const packaged_task&) = delete;
      // Move support
      // Move support
      packaged_task(packaged_task&& __other) noexcept
      packaged_task(packaged_task&& __other) noexcept
      { this->swap(__other); }
      { this->swap(__other); }
      template
      template
        explicit
        explicit
        packaged_task(allocator_arg_t, const _Allocator&,
        packaged_task(allocator_arg_t, const _Allocator&,
                      packaged_task&& __other) noexcept
                      packaged_task&& __other) noexcept
        { this->swap(__other); }
        { this->swap(__other); }
      packaged_task& operator=(packaged_task&& __other) noexcept
      packaged_task& operator=(packaged_task&& __other) noexcept
      {
      {
        packaged_task(std::move(__other)).swap(*this);
        packaged_task(std::move(__other)).swap(*this);
        return *this;
        return *this;
      }
      }
      void
      void
      swap(packaged_task& __other) noexcept
      swap(packaged_task& __other) noexcept
      { _M_state.swap(__other._M_state); }
      { _M_state.swap(__other._M_state); }
      bool
      bool
      valid() const noexcept
      valid() const noexcept
      { return static_cast(_M_state); }
      { return static_cast(_M_state); }
      // Result retrieval
      // Result retrieval
      future<_Res>
      future<_Res>
      get_future()
      get_future()
      { return future<_Res>(_M_state); }
      { return future<_Res>(_M_state); }
      // Execution
      // Execution
      void
      void
      operator()(_ArgTypes... __args)
      operator()(_ArgTypes... __args)
      {
      {
        __future_base::_State_base::_S_check(_M_state);
        __future_base::_State_base::_S_check(_M_state);
        _M_state->_M_run(std::forward<_ArgTypes>(__args)...);
        _M_state->_M_run(std::forward<_ArgTypes>(__args)...);
      }
      }
      void
      void
      reset()
      reset()
      {
      {
        __future_base::_State_base::_S_check(_M_state);
        __future_base::_State_base::_S_check(_M_state);
        packaged_task(std::move(_M_state->_M_task)).swap(*this);
        packaged_task(std::move(_M_state->_M_task)).swap(*this);
      }
      }
    };
    };
  /// swap
  /// swap
  template
  template
    inline void
    inline void
    swap(packaged_task<_Res(_ArgTypes...)>& __x,
    swap(packaged_task<_Res(_ArgTypes...)>& __x,
         packaged_task<_Res(_ArgTypes...)>& __y) noexcept
         packaged_task<_Res(_ArgTypes...)>& __y) noexcept
    { __x.swap(__y); }
    { __x.swap(__y); }
  template
  template
    struct uses_allocator, _Alloc>
    struct uses_allocator, _Alloc>
    : public true_type { };
    : public true_type { };
  template
  template
    class __future_base::_Deferred_state final
    class __future_base::_Deferred_state final
    : public __future_base::_State_base
    : public __future_base::_State_base
    {
    {
    public:
    public:
      explicit
      explicit
      _Deferred_state(_BoundFn&& __fn)
      _Deferred_state(_BoundFn&& __fn)
      : _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
      : _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
      { }
      { }
    private:
    private:
      typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
      typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
      _Ptr_type _M_result;
      _Ptr_type _M_result;
      _BoundFn _M_fn;
      _BoundFn _M_fn;
      virtual void
      virtual void
      _M_run_deferred()
      _M_run_deferred()
      {
      {
        // safe to call multiple times so ignore failure
        // safe to call multiple times so ignore failure
        _M_set_result(_S_task_setter(_M_result, _M_fn), true);
        _M_set_result(_S_task_setter(_M_result, _M_fn), true);
      }
      }
    };
    };
  class __future_base::_Async_state_common : public __future_base::_State_base
  class __future_base::_Async_state_common : public __future_base::_State_base
  {
  {
  protected:
  protected:
#ifdef _GLIBCXX_HAVE_TLS
#ifdef _GLIBCXX_HAVE_TLS
    ~_Async_state_common();
    ~_Async_state_common();
#else
#else
    ~_Async_state_common() { _M_join(); }
    ~_Async_state_common() { _M_join(); }
#endif
#endif
    // Allow non-timed waiting functions to block until the thread completes,
    // Allow non-timed waiting functions to block until the thread completes,
    // as if joined.
    // as if joined.
    virtual void _M_run_deferred() { _M_join(); }
    virtual void _M_run_deferred() { _M_join(); }
    void _M_join() { std::call_once(_M_once, &thread::join, ref(_M_thread)); }
    void _M_join() { std::call_once(_M_once, &thread::join, ref(_M_thread)); }
    thread _M_thread;
    thread _M_thread;
    once_flag _M_once;
    once_flag _M_once;
  };
  };
  template
  template
    class __future_base::_Async_state_impl final
    class __future_base::_Async_state_impl final
    : public __future_base::_Async_state_common
    : public __future_base::_Async_state_common
    {
    {
    public:
    public:
      explicit
      explicit
      _Async_state_impl(_BoundFn&& __fn)
      _Async_state_impl(_BoundFn&& __fn)
      : _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
      : _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
      {
      {
        _M_thread = std::thread{ [this] {
        _M_thread = std::thread{ [this] {
          _M_set_result(_S_task_setter(_M_result, _M_fn));
          _M_set_result(_S_task_setter(_M_result, _M_fn));
        } };
        } };
      }
      }
    private:
    private:
      typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
      typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
      _Ptr_type _M_result;
      _Ptr_type _M_result;
      _BoundFn _M_fn;
      _BoundFn _M_fn;
    };
    };
  template
  template
    inline std::shared_ptr<__future_base::_State_base>
    inline std::shared_ptr<__future_base::_State_base>
    __future_base::_S_make_deferred_state(_BoundFn&& __fn)
    __future_base::_S_make_deferred_state(_BoundFn&& __fn)
    {
    {
      typedef typename remove_reference<_BoundFn>::type __fn_type;
      typedef typename remove_reference<_BoundFn>::type __fn_type;
      typedef _Deferred_state<__fn_type> __state_type;
      typedef _Deferred_state<__fn_type> __state_type;
      return std::make_shared<__state_type>(std::move(__fn));
      return std::make_shared<__state_type>(std::move(__fn));
    }
    }
  template
  template
    inline std::shared_ptr<__future_base::_State_base>
    inline std::shared_ptr<__future_base::_State_base>
    __future_base::_S_make_async_state(_BoundFn&& __fn)
    __future_base::_S_make_async_state(_BoundFn&& __fn)
    {
    {
      typedef typename remove_reference<_BoundFn>::type __fn_type;
      typedef typename remove_reference<_BoundFn>::type __fn_type;
      typedef _Async_state_impl<__fn_type> __state_type;
      typedef _Async_state_impl<__fn_type> __state_type;
      return std::make_shared<__state_type>(std::move(__fn));
      return std::make_shared<__state_type>(std::move(__fn));
    }
    }
  /// async
  /// async
  template
  template
    future::type>
    future::type>
    async(launch __policy, _Fn&& __fn, _Args&&... __args)
    async(launch __policy, _Fn&& __fn, _Args&&... __args)
    {
    {
      typedef typename result_of<_Fn(_Args...)>::type result_type;
      typedef typename result_of<_Fn(_Args...)>::type result_type;
      std::shared_ptr<__future_base::_State_base> __state;
      std::shared_ptr<__future_base::_State_base> __state;
      if ((__policy & (launch::async|launch::deferred)) == launch::async)
      if ((__policy & (launch::async|launch::deferred)) == launch::async)
        {
        {
          __state = __future_base::_S_make_async_state(std::__bind_simple(
          __state = __future_base::_S_make_async_state(std::__bind_simple(
              std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
              std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
        }
        }
      else
      else
        {
        {
          __state = __future_base::_S_make_deferred_state(std::__bind_simple(
          __state = __future_base::_S_make_deferred_state(std::__bind_simple(
              std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
              std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
        }
        }
      return future(__state);
      return future(__state);
    }
    }
  /// async, potential overload
  /// async, potential overload
  template
  template
    inline typename
    inline typename
    __async_sfinae_helper::type, _Fn, _Args...>::type
    __async_sfinae_helper::type, _Fn, _Args...>::type
    async(_Fn&& __fn, _Args&&... __args)
    async(_Fn&& __fn, _Args&&... __args)
    {
    {
      return async(launch::async|launch::deferred, std::forward<_Fn>(__fn),
      return async(launch::async|launch::deferred, std::forward<_Fn>(__fn),
                   std::forward<_Args>(__args)...);
                   std::forward<_Args>(__args)...);
    }
    }
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
       // && ATOMIC_INT_LOCK_FREE
       // && ATOMIC_INT_LOCK_FREE
  // @} group futures
  // @} group futures
_GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
} // namespace
#endif // __GXX_EXPERIMENTAL_CXX0X__
#endif // __GXX_EXPERIMENTAL_CXX0X__
#endif // _GLIBCXX_FUTURE
#endif // _GLIBCXX_FUTURE
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.