33.10 Futures [futures] C++N4910:2022 (716) p1739.cpp

# はじめに(Introduction)

N4910  Working Draft, Standard for Programming Language C++

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf

C++ n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 のWG21を含むいくつかのWGでは、可能な限り作業文書を公開し、幅広い意見を求めています。

ISO/IEC JTC1 SC7からISO/IEC JTC1 SC22リエゾンとして、2000年頃、C/C++の品質向上に貢献しようとした活動をしていたことがあります。その頃は、まだISO/IEC TS 17961の原案が出る前です。Cの精神が優勢で、セキュリティ対策は補助的な位置付けでした。ISO/IEC TS 17961の制定と、C/C++のライブラリ類の見直しと、C++の進化はどんどん進んでいきます。　

進化の具合が、どちらに行こうとしているかは、コンパイルて実行させてみないとわかりません。C/C++の規格案の電子ファイルは、そのままコンパイルできる形式であるとよいと主張してきました。MISRA-C/C++, CERTC/C++でも同様です。MISRA-C/C++は、Example Suiteという形で、コード断片をコンパイルできる形で提供するようになりました。

一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, 箱庭プロジェクト、g++(GCC), clang++(LLVM）との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。

## 背景(back ground)
C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに１回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。

この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を１０種類以上、最近になって解決できたことがあります。それは、主に次の３つの情報に基づいています。

https://stackoverflow.com

http://ja.cppreference.com/

cpprefjp - C++日本語リファレンス

https://cpprefjp.github.io/

コンパイラの実装状況

https://cpprefjp.github.io/implementation-status.html

また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。

## 作業方針(sequence)
Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの２種類
でコンパイルし、

１）コンパイルエラーを収集する。
２）コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
３）リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
４）意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。

１）だけのものから４）まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。

### C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list  

https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

```macOS:bash
$ docker run -v /Users/ogawakiyoshi/n4910:/Users/ogawakiyoshi/n4910 -it kaizenjapan/n4910 /bin/bash
```

### C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010

### C++N4606, 2016符号断片編纂一覧(example code compile list)
C++N4606, 2016 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/

### C++N3242, 2011 sample code compile list on clang++ and g++
https://qiita.com/kaizen_nagoya/items/685b5c1a2c17c1bf1318

## 読書感想文

CコンパイラによるC言語規格の読書感想文として掲載しています。

コンパイル実験が、C++N4910に対する、G++とClang++による感想文だということご理解いただけると幸いです。

読書感想文は人間かAIだけが作るものとは限りません。
本（電子書籍を含む）を入力として、その内容に対する文字列を読書感想文として受け止めましょう。
元の文章をあり方、コンパイルできるように電子化しておくこと、コンパイラが解釈可能な断片の作り方など。

https://qiita.com/tags/読書感想文

## 個人開発

Cコンパイラの試験を一人でもくもくとやっているのは個人開発の一つの姿です。

https://qiita.com/tags/個人開発

 <この項は書きかけです。順次追記します。>

## 編纂器(Compiler)
### clang++ --version
#####  20220826 以前
> Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
Target: x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin

##### 20220827 以降
> Debian clang version 14.0.6-++20220622053050+f28c006a5895-1~exp1~20220622173135.152
Target: x86_64-pc-linux-gnu　Thread model: posix InstalledDir: /usr/bin

### g++- --version
> g++ (GCC) 12.1.0  Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# 33.10 Futures [futures] C++N4910:2022 (716) p1739.cpp

## 算譜(source code)

```c++:p1739.cpp
// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "33.10 Futures [futures] C++N4910:2022 (716) p1739.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. OGAWA Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91

#include "N4910.h"

using namespace std;

// Returns: A reference to an object of a type derived from class error_category.
// The object’s default_error_condition and equivalent virtual functions shall behave as specified for


// 33.10.1 Overview [futures.overview]
// 33.10 describes components that a C++ program can use to retrieve in one thread the result (value or exception) from a function that has run in the same thread or another thread.
// [Note 1: These components are not restricted to multi-threaded programs but can be useful in single-threaded programs as well.
// 33.10.2 Header <future> synopsis [future.syn]
namespace std {
enum class future_errc {
    broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
};
enum class launch : unspecified { async = unspecified,
                                  deferred = unspecified, implementation-defined
                                };
enum class future_status {
    ready,timeout, deferred
};
// 33.10.3, error handling [futures.errors]
template<> struct is_error_code_enum<future_errc> : public true_type { };
error_code make_error_code(future_errc e) noexcept;
error_condition make_error_condition(future_errc e) noexcept;
const error_category& future_category() noexcept;
// 33.10.4, class future_error class future_error;
// 33.10.6, class template promise template<class R> class promise; template<class R> class promise<R&>; template<> class promise<void>;
template<class R>
void swap(promise<R>& x, promise<R>& y) noexcept;
template<class R, class Alloc>
struct uses_allocator<promise<R>, Alloc>;
// 33.10.7, class template future template<class R> class future; template<class R> class future<R&>; template<> class future<void>;
// 33.10.8, class template shared_future template<class R> class shared_future; template<class R> class shared_future<R&>; template<> class shared_future<void>;
// 33.10.10, class template packaged_task template<class> class packaged_task; // not defined template<class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)>;
template<class R, class... ArgTypes>
void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
// 33.10.9, function template async template<class F, class... Args>
[[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
        async(F&& f, Args&&... args);
template<class F, class... Args>
[[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
        async(launch policy, F&& f, Args&&... args);
}
//  The enum type launch is a bitmask type (16.3.3.3.4) with elements launch::async and launch::deferred.
// [Note 1: Implementations can provide bitmasks to specify restrictions on task interaction by functions launched by async() applicable to a corresponding subset of available launch policies. Implementations can extend the behavior of the first overload of async() by adding their extensions to the launch policy under the “as if” rule.
//  The enum values of future_errc are distinct and not zero. 33.10.3 Error handling
const error_category& future_category() noexcept;
// the class error_category. The object’s name virtual function returns a pointer to the string "future".
error_code make_error_code(future_errc e) noexcept;
// Returns: error_code(static_cast<int>(e), future_category()).
error_condition make_error_condition(future_errc e) noexcept;
// Returns: error_condition(static_cast<int>(e), future_category()).
// 33.10.4 Class future_error [futures.future.error]
namespace std {
class future_error : public logic_error {
public:
    explicit future_error(future_errc e);
    const error_code& code() const noexcept;
    const char*       what() const noexcept;
// — if the return object or provider holds the last reference to its shared state, the shared state is destroyed; and
// — the return object or provider gives up its reference to its shared state; and
// — these actions will not block for the shared state to become ready, except that it may block if all of the following are true: the shared state was created by a call to std::async, the shared state is not yet ready, and this was the last reference to the shared state.
// — first, the provider marks its shared state as ready; and
private:
    error_code ec_; // exposition only
};
}
explicit future_error(future_errc e);
// Effects: Initializes ec_ with make_error_code(e). const error_code& code() const noexcept;
// Returns: ec_.
const char* what() const noexcept;
// Returns: An ntbs incorporating code().message().
// 33.10.5 Shared state [futures.state]
//  Many of the classes introduced in subclause 33.10 use some state to communicate results. This shared state consists of some state information and some (possibly not yet evaluated) result, which can be a (possibly void) value or an exception.
// [Note 1: Futures, promises, and tasks defined in this Clause reference such shared state. —end note]
// [Note 2: The result can be any kind of object including a function to compute that result, as used by async when policy is launch::deferred. —end note]
//  An asynchronous return object is an object that reads results from a shared state. A waiting function of an asynchronous return object is one that potentially blocks to wait for the shared state to be made ready. If a waiting function can return before the state is made ready because of a timeout (33.2.5), then it is a timed waiting function, otherwise it is a non-timed waiting function.
//  An asynchronous provider is an object that provides a result to a shared state. The result of a shared state is set by respective functions on the asynchronous provider.
// [Note 3: Such as promises or tasks.
// The means of setting the result of a shared state is specified in the description of those classes and functions that create such a state object.
//  When an asynchronous return object or an asynchronous provider is said to release its shared state, it means:
//  When an asynchronous provider is said to make its shared state ready, it means:
// — second, the provider unblocks any execution agents waiting for its shared state to become ready. 7 When an asynchronous provider is said to abandon its shared state, it means:
// — first, if that state is not ready, the provider
// — stores an exception object of type future_error with an error condition of broken_promise within its shared state; and then
// — makes its shared state ready;
// — second, the provider releases its shared state.
//  A shared state is ready only if it holds a value or an exception ready for retrieval. Waiting for a shared state to become ready may invoke code to compute the result on the waiting thread if so specified in the description of the class or function that creates the state object.
//  Calls to functions that successfully set the stored result of a shared state synchronize with (6.9.2) calls to functions successfully detecting the ready state resulting from that setting. The storage of the result (whether normal or exceptional) into the shared state synchronizes with (6.9.2) the successful return from a call to a waiting function on the shared state.
//  Some functions (e.g., promise::set_value_at_thread_exit) delay making the shared state ready until the calling thread exits. The destruction of each of that thread’s objects with thread storage duration (6.7.5.3) is sequenced before making that shared state ready.
//  Access to the result of the same shared state may conflict (6.9.2).
// [Note 4: This explicitly specifies that the result of the shared state is visible in the objects that reference this state in the sense of data race avoidance (16.4.6.10). For example, concurrent accesses through references returned by shared_future::get() (33.10.8) must either use read-only operations or provide additional synchronization. — end note ]
// 33.10.6 Class template promise [futures.promise]
namespace std {
template<class R>
class promise {
public:
    promise();
    template<class Allocator>
    promise(allocator_arg_t, const Allocator& a);
    promise(promise&& rhs) noexcept;
    promise(const promise&) = delete;
    ~promise();
// assignment
    promise& operator=(promise&& rhs) noexcept;
    promise& operator=(const promise&) = delete;
    void swap(promise& other) noexcept;
// retrieving the result
    future<R> get_future();
// setting the result
    void set_value(see below);
    void set_exception(exception_ptr p);
// setting the result with deferred notification
    void set_value_at_thread_exit(see below);
    void set_exception_at_thread_exit(exception_ptr p);
};
template<class R, class Alloc>
struct uses_allocator<promise<R>, Alloc>;
}
//  For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.
//  The implementation provides the template promise and two specializations, promise<R&> and promise< void>. These differ only in the argument type of the member functions set_value and set_value_at_- thread_exit, as set out in their descriptions, below.
//  The set_value, set_exception, set_value_at_thread_exit, and set_exception_at_thread_exit mem- ber functions behave as though they acquire a single mutex associated with the promise object while updating the promise object.
template<class R, class Alloc>
struct uses_allocator<promise<R>, Alloc>
    : true_type { };
// Preconditions: Alloc meets the Cpp17Allocator requirements (16.4.4.6.1). promise();
template<class Allocator>
promise(allocator_arg_t, const Allocator& a);
// Effects: Creates a shared state. The second constructor uses the allocator a to allocate memory for the shared state.
promise(promise&& rhs) noexcept;
// Effects: Transfers ownership of the shared state of rhs (if any) to the newly-constructed object. Postconditions: rhs has no shared state.
~promise();
// Effects: Abandons any shared state (33.10.5).
promise& operator=(promise&& rhs) noexcept;
// Effects: Abandons any shared state (33.10.5) and then as if promise(std::move(rhs)).swap(*this). Returns: *this.
void swap(promise& other) noexcept;
// Effects: Exchanges the shared state of *this and other.
// Postconditions: *this has the shared state (if any) that other had prior to the call to swap. other has the shared state (if any) that *this had prior to the call to swap.
future<R> get_future();
// Synchronization: Calls to this function do not introduce data races (6.9.2) with calls to set_value, set_exception, set_value_at_thread_exit, or set_exception_at_thread_exit.
// [Note 1: Such calls need not synchronize with each other.
// Returns: A future<R> object with the same shared state as *this.
// Throws: future_error if *this has no shared state or if get_future has already been called on a promise with the same shared state as *this.
// Error conditions: — future_already_retrieved if get_future has already been called on a promise with the same shared state as *this.
// — no_state if *this has no shared state.
void promise::set_value(const R& r);
void promise::set_value(R&& r);
void promise<R&>::set_value(R& r);
void promise<void>::set_value();
// Effects: Atomically stores the value r in the shared state and makes that state ready (33.10.5). Throws:
// — future_error if its shared state already has a stored value or exception, or
// — for the first version, any exception thrown by the constructor selected to copy an object of R, or — for the second version, any exception thrown by the constructor selected to move an object of R.
// Error conditions: — promise_already_satisfied if its shared state already has a stored value or exception. — no_state if *this has no shared state.
void set_exception(exception_ptr p);
// Preconditions: p is not null.
// Effects: Atomically stores the exception pointer p in the shared state and makes that state ready
(33.10.5).
// Throws: future_error if its shared state already has a stored value or exception. Error conditions:
// — promise_already_satisfied if its shared state already has a stored value or exception. — no_state if *this has no shared state.
void promise::set_value_at_thread_exit(const R& r);
void promise::set_value_at_thread_exit(R&& r);
void promise<R&>::set_value_at_thread_exit(R& r);
void promise<void>::set_value_at_thread_exit();
// Effects: Stores the value r in the shared state without making that state ready immediately. Schedules that state to be made ready when the current thread exits, after all objects of thread storage duration associated with the current thread have been destroyed.
// Throws: — future_error if its shared state already has a stored value or exception, or
// — for the first version, any exception thrown by the constructor selected to copy an object of R, or — for the second version, any exception thrown by the constructor selected to move an object of R.
// Error conditions: — promise_already_satisfied if its shared state already has a stored value or exception. — no_state if *this has no shared state.
void set_exception_at_thread_exit(exception_ptr p);
// Preconditions: p is not null.
// Effects: Stores the exception pointer p in the shared state without making that state ready immediately. Schedules that state to be made ready when the current thread exits, after all objects of thread storage duration associated with the current thread have been destroyed.
// Throws: future_error if an error condition occurs. Error conditions:
// — promise_already_satisfied if its shared state already has a stored value or exception. — no_state if *this has no shared state.
template<class R>
void swap(promise<R>& x, promise<R>& y) noexcept;
// Effects: As if by x.swap(y). 33.10.7 Class template future
// [futures.unique.future]
// The class template future defines a type for asynchronous return objects which do not share their shared state with other asynchronous return objects. A default-constructed future object has no shared state. A future object with shared state can be created by functions on asynchronous providers (33.10.5) or by the move constructor and shares its shared state with the original asynchronous provider. The result (value or exception) of a future object can be set by calling a respective function on an object that shares the same shared state.
// [Note 1 : Member functions of future do not synchronize with themselves or with member functions of shared_future.
// The effect of calling any member function other than the destructor, the move-assignment operator, share, or valid on a future object for which valid() == false is undefined.
// [Note 2: It is valid to move from a future object for which valid() == false.
// Recommended practice: Implementations should detect this case and throw an object of type future_error with an error condition of future_errc::no_state.
namespace std {
template<class R>
class future {
public:
    future() noexcept;
    future(future&&) noexcept;
    future(const future&) = delete;
// Effects: The object does not refer to a shared state. Postconditions: valid() == false.
    ~future();
    future& operator=(const future&) = delete;
    future& operator=(future&&) noexcept;
    shared_future<R> share() noexcept;
// retrieving the value
    see below get();
// functions to check state
    bool valid() const noexcept;
    void wait() const;
    template<class Rep, class Period>
    future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
    template<class Clock, class Duration>
    future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
}
//  For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.
//  The implementation provides the template future and two specializations, future<R&> and future<void>. These differ only in the return type and return value of the member function get, as set out in its description, below.
future() noexcept;
future(future&& rhs) noexcept;
// Effects: Move constructs a future object that refers to the shared state that was originally referred to by rhs (if any).
// Postconditions:— valid() returns the same value as rhs.valid() prior to the constructor invocation. — rhs.valid() == false.
~future();
Effects:
// — Releases any shared state (33.10.5); — destroys *this.
future& operator=(future&& rhs) noexcept;
// Effects:— Releases any shared state (33.10.5).
// — move assigns the contents of rhs to *this.
// Postconditions:— valid() returns the same value as rhs.valid() prior to the assignment. — rhs.valid() == false.
shared_future<R> share() noexcept;
// Postconditions: valid() == false.
// Returns: shared_future<R>(std::move(*this)).
R future::get();
R& future<R&>::get();
void future<void>::get();
//  The class template shared_future defines a type for asynchronous return objects which may share their shared state with other asynchronous return objects. A default-constructed shared_future object has no shared state. A shared_future object with shared state can be created by conversion from a future object and shares its shared state with the original asynchronous provider (33.10.5) of the shared state. The result value or exception) of a shared_future object can be set by calling a respective function on an object that shares the same shared state.
//  [Note 1: Member functions of shared_future do not synchronize with themselves, but they synchronize with the shared state. —end note]
// [Note 3: As described above, the template and its two required specializations differ only in the return type and return value of the member function get. —end note]
// Effects:— wait()s until the shared state is ready, then retrieves the value stored in the shared state; — releases any shared state (33.10.5).
// Postconditions: valid() == false. Returns:
// — future::get() returns the value v stored in the object’s shared state as std::move(v). — future<R&>::get() returns the reference stored as value in the object’s shared state. — future<void>::get() returns nothing.
// Throws: The stored exception, if an exception was stored in the shared state. bool valid() const noexcept;
// Returns: true only if *this refers to a shared state. void wait() const;
// Effects: Blocks until the shared state is ready.
template<class Rep, class Period>
future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
// Effects: None if the shared state contains a deferred function (33.10.9), otherwise blocks until the shared state is ready or until the relative timeout (33.2.4) specified by rel_time has expired.
// Returns:— future_status::deferred if the shared state contains a deferred function.
// — future_status::ready if the shared state is ready.
// — future_status::timeout if the function is returning because the relative timeout (33.2.4) specified by rel_time has expired.
// Throws: timeout-related exceptions (33.2.4). template<class Clock, class Duration>
future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
// Effects: None if the shared state contains a deferred function (33.10.9), otherwise blocks until the shared state is ready or until the absolute timeout (33.2.4) specified by abs_time has expired.
// Returns:— future_status::deferred if the shared state contains a deferred function.
// — future_status::ready if the shared state is ready.
// — future_status::timeout if the function is returning because the absolute timeout (33.2.4) specified by abs_time has expired.
// Throws: timeout-related exceptions (33.2.4).
// 33.10.8 Class template shared_future [futures.shared.future]
// Effects: The object does not refer to a shared state. Postconditions: valid() == false.
//  The effect of calling any member function other than the destructor, the move-assignment operator, the copy-assignment operator, or valid() on a shared_future object for which valid() == false is undefined.
// [Note 2: It is valid to copy or move from a shared_future object for which valid() is false.
// Recommended practice: Implementations should detect this case and throw an object of type future_error with an error condition of future_errc::no_state.
namespace std {
template<class R>
class shared_future {
public:
    shared_future() noexcept;
    shared_future(const shared_future& rhs) noexcept;
    shared_future(future<R>&&) noexcept;
    shared_future(shared_future&& rhs) noexcept;
    ~shared_future();
    shared_future& operator=(const shared_future& rhs) noexcept;
    shared_future& operator=(shared_future&& rhs) noexcept;
// retrieving the value
    see below get() const; // functions to check state
    bool valid() const noexcept;
    void wait() const;
    template<class Rep, class Period>
    future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
    template<class Clock, class Duration>
    future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
}
// For the primary template, R shall be an object type that meets the Cpp17Destructible requirements.
//  The implementation provides the template shared_future and two specializations, shared_future<R&> and shared_future<void>. These differ only in the return type and return value of the member function get, as set out in its description, below.
shared_future() noexcept;
shared_future(const shared_future& rhs) noexcept;
// Effects: The object refers to the same shared state as rhs (if any). Postconditions: valid() returns the same value as rhs.valid().
shared_future(future<R>&& rhs) noexcept;
shared_future(shared_future&& rhs) noexcept;
// Effects: Move constructs a shared_future object that refers to the shared state that was originally referred to by rhs (if any).
// Postconditions:— valid() returns the same value as rhs.valid() returned prior to the constructor invocation. — rhs.valid() == false.
~shared_future();
Effects:
// — Releases any shared state (33.10.5); — destroys *this.
shared_future& operator=(shared_future&& rhs) noexcept;
// Effects:— Releases any shared state (33.10.5);
// — move assigns the contents of rhs to *this.
// Postconditions:— valid() returns the same value as rhs.valid() returned prior to the assignment. — rhs.valid() == false.
shared_future& operator=(const shared_future& rhs) noexcept;
// Effects:— Releases any shared state (33.10.5);
// — assigns the contents of rhs to *this.
// [Note 3: As a result, *this refers to the same shared state as rhs (if any).
// Postconditions: valid() == rhs.valid().
const R& shared_future::get() const;
R& shared_future<R&>::get() const;
void shared_future<void>::get() const;
// [Note 4: As described above, the template and its two required specializations differ only in the return type and return value of the member function get.
// [Note 5: Access to a value object stored in the shared state is unsynchronized, so operations on R might introduce a data race (6.9.2).
// Effects: wait()s until the shared state is ready, then retrieves the value stored in the shared state. Returns:
// — shared_future::get() returns a const reference to the value stored in the object’s shared state.
// [Note 6: Access through that reference after the shared state has been destroyed produces undefined behavior; this can be avoided by not storing the reference in any storage with a greater lifetime than the shared_future object that returned the reference.
// — shared_future<R&>::get() returns the reference stored as value in the object’s shared state.
// — shared_future<void>::get() returns nothing.
// Throws: The stored exception, if an exception was stored in the shared state.
bool valid() const noexcept;
// Returns: true only if *this refers to a shared state. void wait() const;
// Effects: Blocks until the shared state is ready.
template<class Rep, class Period>
future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
// Effects: None if the shared state contains a deferred function (33.10.9), otherwise blocks until the shared state is ready or until the relative timeout (33.2.4) specified by rel_time has expired.
// Returns:— future_status::deferred if the shared state contains a deferred function.
// — future_status::ready if the shared state is ready.
// — future_status::timeout if the function is returning because the relative timeout (33.2.4) specified by rel_time has expired.
// Throws: timeout-related exceptions (33.2.4).
template<class Clock, class Duration>
future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
[[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
        async(launch policy, F&& f, Args&&... args);
// Mandates: The following are all true:
// — is_constructible_v<decay_t<F>, F>,
// — (is_constructible_v<decay_t<Args>, Args> && ...), and — is_invocable_v<decay_t<F>, decay_t<Args>...>.
// Effects: The first function behaves the same as a call to the second function with a policy argument of launch::async | launch::deferred and the same arguments for F and Args. The second function creates a shared state that is associated with the returned future object. The further behavior of the second function depends on the policy argument as follows (if more than one of these conditions applies, the implementation may choose any of the corresponding policies):
// — If launch::async is set in policy, calls invoke(auto(std::forward<F>(f)), auto(std::for- ward<Args>(args))...) (22.10.4, 33.4.3.3) as if in a new thread of execution represented by a thread object with the values produced by auto being materialized (7.3.5) in the thread that called async. Any return value is stored as the result in the shared state. Any exception propagated from the execution of invoke(auto(std::forward<F>(f)), auto(std::forward<Args>(args))...) is stored as the exceptional result in the shared state. The thread object is stored in the shared state and affects the behavior of any asynchronous return objects that reference that state.
// — If launch::deferred is set in policy, stores auto(std::forward<F>(f)) and auto(std::for- ward<Args>(args))... in the shared state. These copies of f and args constitute a deferred function. Invocation of the deferred function evaluates invoke(std::move(g), std::move(xyz)) where g is the stored value of auto(std::forward<F>(f)) and xyz is the stored copy of auto(std::forward<Args>(args)).... Any return value is stored as the result in the shared state. Any exception propagated from the execution of the deferred function is stored as the exceptional result in the shared state. The shared state is not made ready until the function has completed. The first call to a non-timed waiting function (33.10.5) on an asynchronous return object referring to this shared state invokes the deferred function in the thread that called the waiting function. Once evaluation of invoke(std::move(g), std::move(xyz)) begins, the function is no longer considered deferred.
// Recommended practice: If this policy is specified together with other policies, such as when using a policy value of launch::async | launch::deferred, implementations should defer invocation or the selection of the policy when no more concurrency can be effectively exploited.
// — If no value is set in the launch policy, or a value is set that is neither specified in this document nor by the implementation, the behavior is undefined.
// Synchronization: The invocation of async synchronizes with the invocation of f. The completion of the function f is sequenced before the shared state is made ready.
// Effects: None if the shared state contains a deferred function (33.10.9), otherwise blocks until the shared state is ready or until the absolute timeout (33.2.4) specified by abs_time has expired.
// Returns: — future_status::deferred if the shared state contains a deferred function.
// — future_status::ready if the shared state is ready.
// — future_status::timeout if the function is returning because the absolute timeout (33.2.4) specified by abs_time has expired.
//  The function template async provides a mechanism to launch a function potentially in a new thread and provides the result of the function in a future object with which it shares a shared state.
template<class F, class... Args>
[[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
        async(F&& f, Args&&... args);
template<class F, class... Args>
Throws:
timeout-related exceptions (33.2.4).
// 33.10.9 Function template async [futures.async]
// [Note 1: These apply regardless of the provided policy argument, and even if the corresponding future object is moved to another thread. However, it is possible for f not to be called at all, in which case its completion never happens.
// If the implementation chooses the launch::async policy,
// — a call to a waiting function on an asynchronous return object that shares the shared state created by this async call shall block until the associated thread has completed, as if joined, or else time out (33.4.3.6);
// — the associated thread completion synchronizes with (6.9.2) the return from the first function that successfully detects the ready status of the shared state or with the return from the last function that releases the shared state, whichever happens first.
// Returns: An object of type future<invoke_result_t<decay_t<F>, decay_t<Args>...>> that refers to the shared state created by this call to async.
// [Note 2: If a future obtained from async is moved outside the local scope, the future’s destructor can block for the shared state to become ready.
// Throws: system_error if policy == launch::async and the implementation is unable to start a new thread, or std::bad_alloc if memory for the internal data structures cannot be allocated.
// Error conditions:— resource_unavailable_try_again — if policy == launch::async and the system is unable to start a new thread.
//  [Example 1 :
int work1(int value);
int work2(int value);
int work(int value) {
    auto handle = std::async([=] { return work2(value); });
    int tmp = work1(value);
    return tmp + handle.get(); // #1
}
// [Note 3: Line #1 might not result in concurrency because the async call uses the default policy, which might use launch::deferred, in which case the lambda might not be invoked until the get() call; in that case, work1 and work2 are called on the same thread and there is no concurrency.
// 33.10.10 Class template packaged_task [futures.task]
// 33.10.10.1 General [futures.task.general]
//  The class template packaged_task defines a type for wrapping a function or callable object so that the return value of the function or callable object is stored in a future when it is invoked.
//  When the packaged_task object is invoked, its stored task is invoked and the result (whether normal or exceptional) stored in the shared state. Any futures that share the shared state will then be able to access the stored result.
namespace std {
template<class> class packaged_task;
template<class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)> {
public:
// construction and destruction
    packaged_task() noexcept;
    template<class F>
    explicit packaged_task(F&& f);
    ~packaged_task();
// no copy
// not defined
    packaged_task(const packaged_task&) = delete;
    packaged_task& operator=(const packaged_task&) = delete;
// move support
    packaged_task(packaged_task&& rhs) noexcept;
    packaged_task& operator=(packaged_task&& rhs) noexcept;
    void swap(packaged_task& other) noexcept;
    bool valid() const noexcept;
// result retrieval
    future<R> get_future();
// execution
    void operator()(ArgTypes... );
    void make_ready_at_thread_exit(ArgTypes...);
    void reset();
};
template<class R, class... ArgTypes>
packaged_task(R (*)(ArgTypes...)) -> packaged_task<R(ArgTypes...)>;
template<class F> packaged_task(F) -> packaged_task<see below>;
}
// 33.10.10.2 Member functions [futures.task.members]
packaged_task() noexcept;
// Effects: The object has no shared state and no stored task.
template<class F>
packaged_task(F&& f);
// Constraints: remove_cvref_t<F> is not the same type as packaged_task<R(ArgTypes...)>.
// Mandates: is_invocable_r_v<R, F&, ArgTypes...> is true.
// Preconditions: Invoking a copy of f behaves the same as invoking f.
// Effects: Constructs a new packaged_task object with a shared state and initializes the object’s stored task with std::forward<F>(f).
// Throws: Any exceptions thrown by the copy or move constructor of f, or bad_alloc if memory for the internal data structures cannot be allocated.
template<class F> packaged_task(F) -> packaged_task<see below>;
// Constraints: &F::operator() is well-formed when treated as an unevaluated operand (7.2.3) and decltype(&F::operator()) is of the form R(G::*)(A...) cv &opt noexceptopt for a class type G. Remarks: The deduced type is packaged_task<R(A...)>.
packaged_task(packaged_task&& rhs) noexcept;
// Effects: Transfers ownership of rhs’s shared state to *this, leaving rhs with no shared state. Moves the stored task from rhs to *this.
// Postconditions: rhs has no shared state.
packaged_task& operator=(packaged_task&& rhs) noexcept;
// Effects:— Releases any shared state (33.10.5);
// — calls packaged_task(std::move(rhs)).swap(*this).
~packaged_task();
// Effects: Abandons any shared state (33.10.5).
void swap(packaged_task& other) noexcept;
// Effects: Exchanges the shared states and stored tasks of *this and other.
// Postconditions: *this has the same shared state and stored task (if any) as other prior to the call to swap. other has the same shared state and stored task (if any) as *this prior to the call to swap.
bool valid() const noexcept;
// Returns: true only if *this has a shared state. future<R> get_future();
// Synchronization: Calls to this function do not introduce data races (6.9.2) with calls to operator() or make_ready_at_thread_exit.
// [Note 1: Such calls need not synchronize with each other.
// Returns: A future object that shares the same shared state as *this. // Throws: A future_error object if an error occurs.
// Error conditions:— future_already_retrieved if get_future has already been called on a packaged_task object with the same shared state as *this.
// — no_state if *this has no shared state.
void operator()(ArgTypes... args);
// Effects: As if by INVOKE<R>(f, t1, t2, . . . , tN ) (22.10.4), where f is the stored task of *this and t1 , t2 , . . . , tN are the values in args.... If the task returns normally, the return value is stored as the asynchronous result in the shared state of *this, otherwise the exception thrown by the task is stored. The shared state of *this is made ready, and any threads blocked in a function waiting for the shared state of *this to become ready are unblocked.
// Throws: A future_error exception object if there is no shared state or the stored task has already been invoked.
// Error conditions:— promise_already_satisfied if the stored task has already been invoked. — no_state if *this has no shared state.
void make_ready_at_thread_exit(ArgTypes... args);
// Effects: As if by INVOKE<R>(f, t1, t2, . . . , tN ) (22.10.4), where f is the stored task and t1, t2, ..., tN are the values in args.... If the task returns normally, the return value is stored as the asynchronous result in the shared state of *this, otherwise the exception thrown by the task is stored. In either case, this is done without making that state ready (33.10.5) immediately. Schedules the shared state to be made ready when the current thread exits, after all objects of thread storage duration associated with the current thread have been destroyed.
// Throws: future_error if an error condition occurs. Error conditions: — promise_already_satisfied if the stored task has already been invoked. — no_state if *this has no shared state.
void reset();
// Effects: As if *this = packaged_task(std::move(f)), where f is the task stored in *this.
// [Note 2: This constructs a new shared state for *this. The old state is abandoned (33.10.5).
//  Throws: — bad_alloc if memory for the new shared state cannot be allocated.
// — any exception thrown by the move constructor of the task stored in the shared state. — future_error with an error condition of no_state if *this has no shared state.
// 33.10.10.3 Globals [futures.task.nonmembers]
template<class R, class... ArgTypes>
void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
// Effects: As if by x.swap(y).
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
```

## 編纂・実行結果(compile and go)

```ubuntu:bash
$ clang++ p1739.cpp -std=03 -o p1739l -I. -Wall
In file included from p1739.cpp:10:
In file included from ./N4910.h:11:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/atomic:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
 ^
p1739.cpp:23:13: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
       enum class future_errc {
            ^
p1739.cpp:24:18: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                 ^
p1739.cpp:24:33: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                ^
p1739.cpp:24:69: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                    ^
p1739.cpp:24:84: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                   ^
p1739.cpp:24:121: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                        ^
p1739.cpp:24:136: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                                       ^
p1739.cpp:24:156: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                                                           ^
p1739.cpp:24:171: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                                                                          ^
p1739.cpp:26:6: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
enum class launch : unspecified { async = unspecified,
     ^
p1739.cpp:26:21: error: unknown type name 'unspecified'
enum class launch : unspecified { async = unspecified,
                    ^
p1739.cpp:26:43: error: use of undeclared identifier 'unspecified'
enum class launch : unspecified { async = unspecified,
                                          ^
p1739.cpp:27:12: error: use of undeclared identifier 'unspecified'
deferred = unspecified, implementation-defined
           ^
p1739.cpp:27:39: error: expected '= constant-expression' or end of enumerator definition
deferred = unspecified, implementation-defined
                                      ^
p1739.cpp:29:13: warning: scoped enumerations are a C++11 extension [-Wc++11-extensions]
       enum class future_status {
            ^
p1739.cpp:32:19: error: explicit specialization of undeclared template struct 'is_error_code_enum'
template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
                  ^                 ~~~~~~~~~~~~~
p1739.cpp:32:60: error: unknown class name 'true_type'; did you mean '__true_type'?
template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
                                                           ^~~~~~~~~
                                                           __true_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/cpp_type_traits.h:73:10: note: '__true_type' declared here
  struct __true_type { };
         ^
p1739.cpp:32:75: error: unknown type name 'error_code'; did you mean 'ios_base::failure::error_code'?
template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
                                                                          ^~~~~~~~~~
                                                                          ios_base::failure::error_code
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/ios_base.h:236:14: note: 'ios_base::failure::error_code' declared here
      struct error_code
             ^
p1739.cpp:32:117: error: expected function body after function declarator
template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
                                                                                                                    ^
p1739.cpp:33:1: error: unknown type name 'error_condition'
error_condition make_error_condition(future_errc e) noexcept;
^
p1739.cpp:33:53: error: expected function body after function declarator
error_condition make_error_condition(future_errc e) noexcept;
                                                    ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.
$ clang++ p1739.cpp -std=2b -o p1739l -I. -Wall
p1739.cpp:24:18: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                 ^
p1739.cpp:24:33: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                ^
p1739.cpp:24:69: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                    ^
p1739.cpp:24:84: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                   ^
p1739.cpp:24:121: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                        ^
p1739.cpp:24:136: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                                       ^
p1739.cpp:24:156: error: use of undeclared identifier 'implementation'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                                                           ^
p1739.cpp:24:171: error: use of undeclared identifier 'defined'
broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
                                                                                                                                                                          ^
p1739.cpp:26:21: error: unknown type name 'unspecified'
enum class launch : unspecified { async = unspecified,
                    ^
p1739.cpp:26:43: error: use of undeclared identifier 'unspecified'
enum class launch : unspecified { async = unspecified,
                                          ^
p1739.cpp:27:12: error: use of undeclared identifier 'unspecified'
deferred = unspecified, implementation-defined
           ^
p1739.cpp:27:39: error: expected '= constant-expression' or end of enumerator definition
deferred = unspecified, implementation-defined
                                      ^
p1739.cpp:38:20: error: no template named 'promise'
         void swap(promise<R>& x, promise<R>& y) noexcept;
                   ^
p1739.cpp:38:35: error: no template named 'promise'
         void swap(promise<R>& x, promise<R>& y) noexcept;
                                  ^
p1739.cpp:40:32: error: use of undeclared identifier 'promise'
         struct uses_allocator<promise<R>, Alloc>;
                               ^
p1739.cpp:44:40: error: pack expansion does not contain any unexpanded parameter packs
         class packaged_task<R(ArgTypes...)>;
                               ~~~~~~~~^
p1739.cpp:44:32: error: use of undeclared identifier 'ArgTypes'
         class packaged_task<R(ArgTypes...)>;
                               ^
p1739.cpp:44:16: error: explicit specialization of undeclared template class 'packaged_task'
         class packaged_task<R(ArgTypes...)>;
               ^            ~~~~~~~~~~~~~~~~
p1739.cpp:46:33: error: expected ')'
         void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
                                ^
p1739.cpp:46:19: note: to match this '('
         void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1739.cpp -std=03 -o p1739g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1739.cpp:10:
/usr/local/include/c++/12.1.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
   32 | #error This file requires compiler and library support \
      |  ^~~~~
p1739.cpp:32:117: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   32 | template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
      |                                                                                                                     ^~~~~~~~
p1739.cpp:165:2: error: too many decimal points in number
  165 | (33.10.5).
      |  ^~~~~~~
p1739.cpp:336:37: error: too many decimal points in number
  336 | Throws: timeout-related exceptions (33.2.4).
      |                                     ^~~~~~
p1739.cpp:23:8: warning: scoped enums only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   23 |        enum class future_errc {
      |        ^~~~
p1739.cpp:24:18: error: 'implementation' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                  ^~~~~~~~~~~~~~
p1739.cpp:24:33: error: 'defined' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                 ^~~~~~~
p1739.cpp:24:69: error: 'implementation' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                     ^~~~~~~~~~~~~~
p1739.cpp:24:84: error: 'defined' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                    ^~~~~~~
p1739.cpp:24:121: error: 'implementation' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                         ^~~~~~~~~~~~~~
p1739.cpp:24:136: error: 'defined' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                                        ^~~~~~~
p1739.cpp:24:156: error: 'implementation' was not declared in this scope
   24 | mise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                                                  ^~~~~~~~~~~~~~

p1739.cpp:24:171: error: 'defined' was not declared in this scope
   24 | ementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                                                      ^~~~~~~

p1739.cpp:26:1: warning: scoped enums only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   26 | enum class launch : unspecified { async = unspecified,
      | ^~~~
p1739.cpp:26:6: warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
   26 | enum class launch : unspecified { async = unspecified,
      | ~~~~ ^~~~~
      |      -----
p1739.cpp:26:19: error: found ':' in nested-name-specifier, expected '::'
   26 | enum class launch : unspecified { async = unspecified,
      |                   ^
      |                   ::
p1739.cpp:26:12: error: 'launch' has not been declared
   26 | enum class launch : unspecified { async = unspecified,
      |            ^~~~~~
p1739.cpp:26:33: error: expected unqualified-id before '{' token
   26 | enum class launch : unspecified { async = unspecified,
      |                                 ^
p1739.cpp:29:8: warning: scoped enums only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   29 |        enum class future_status {
      |        ^~~~
p1739.cpp:32:19: error: 'is_error_code_enum' is not a class template
   32 | template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
      |                   ^~~~~~~~~~~~~~~~~~
p1739.cpp:32:70: error: expected class-name before '{' token
   32 | template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
      |                                                                      ^
p1739.cpp:32:70: error: explicit specialization of non-template 'std::is_error_code_enum'
p1739.cpp:32:75: error: 'error_code' does not name a type
   32 | template<> struct is_error_code_enum<future_errc> : public true_type { }; error_code make_error_code(future_errc e) noexcept;
      |                                                                           ^~~~~~~~~~
p1739.cpp:33:1: error: 'error_condition' does not name a type
   33 | error_condition make_error_condition(future_errc e) noexcept;
      | ^~~~~~~~~~~~~~~
p1739.cpp:34:14: error: 'error_category' does not name a type
   34 |        const error_category& future_category() noexcept;
      |              ^~~~~~~~~~~~~~
p1739.cpp:38:15: error: variable or field 'swap' declared void
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |               ^~~~
p1739.cpp:38:20: error: 'promise' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                    ^~~~~~~
p1739.cpp:38:20: note: 'std::promise' is only available from C++11 onwards
p1739.cpp:38:29: error: expected primary-expression before '>' token
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                             ^
p1739.cpp:38:32: error: 'x' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                ^
p1739.cpp:38:35: error: 'promise' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                   ^~~~~~~
p1739.cpp:38:35: note: 'std::promise' is only available from C++11 onwards
p1739.cpp:38:44: error: expected primary-expression before '>' token
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                            ^
p1739.cpp:38:47: error: 'y' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                               ^
p1739.cpp:40:17: error: 'uses_allocator' is not a class template
   40 |          struct uses_allocator<promise<R>, Alloc>;
      |                 ^~~~~~~~~~~~~~
p1739.cpp:40:32: error: 'promise' was not declared in this scope
   40 |          struct uses_allocator<promise<R>, Alloc>;
      |                                ^~~~~~~
p1739.cpp:40:32: note: 'std::promise' is only available from C++11 onwards
p1739.cpp:40:31: error: expected ';' before ',' token
   40 |          struct uses_allocator<promise<R>, Alloc>;
      |                               ^          ~
      |                               ;
p1739.cpp:44:16: error: 'packaged_task' is not a class template
   44 |          class packaged_task<R(ArgTypes...)>;
      |                ^~~~~~~~~~~~~
p1739.cpp:44:32: error: 'ArgTypes' was not declared in this scope
   44 |          class packaged_task<R(ArgTypes...)>;
      |                                ^~~~~~~~
p1739.cpp:44:43: error: a function call cannot appear in a constant-expression
   44 |          class packaged_task<R(ArgTypes...)>;
      |                                           ^
p1739.cpp:45:31: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   45 |        template<class R, class... ArgTypes>
      |                               ^~~
p1739.cpp:46:20: error: 'std::packaged_task' is not a template
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                    ^~~~~~~~~~~~~
p1739.cpp:46:44: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                                            ^~~
p1739.cpp:46:52: error: 'std::packaged_task' is not a template
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                                                    ^~~~~~~~~~~~~
p1739.cpp:46:76: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                                                                            ^~~
p1739.cpp:46:84: error: expected initializer before 'noexcept'
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                                                                                    ^~~~~~~~
p1739.cpp:48:10: error: expected unqualified-id before '[' token
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |          ^
p1739.cpp:50:31: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   50 |        template<class F, class... Args>
      |                               ^~~
p1739.cpp:51:10: error: expected unqualified-id before '[' token
   51 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |          ^
p1739.cpp:57:7: error: 'error_category' does not name a type
   57 | const error_category& future_category() noexcept;
      |       ^~~~~~~~~~~~~~
p1739.cpp:59:1: error: 'error_code' does not name a type
   59 | error_code make_error_code(future_errc e) noexcept;
      | ^~~~~~~~~~
p1739.cpp:61:1: error: 'error_condition' does not name a type
   61 | error_condition make_error_condition(future_errc e) noexcept;
      | ^~~~~~~~~~~~~~~
p1739.cpp:68:13: error: 'error_code' does not name a type
   68 |       const error_code& code() const noexcept;
      |             ^~~~~~~~~~
p1739.cpp:69:32: error: expected ';' at end of member declaration
   69 |       const char*       what() const noexcept;
      |                                ^~~~~
      |                                     ;
p1739.cpp:69:38: error: 'noexcept' does not name a type
   69 |       const char*       what() const noexcept;
      |                                      ^~~~~~~~
p1739.cpp:69:38: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:75:1: error: 'error_code' does not name a type
   75 | error_code ec_; // exposition only
      | ^~~~~~~~~~
p1739.cpp:69:25: error: looser exception specification on overriding virtual function 'virtual const char* std::future_error::what() const'
   69 |       const char*       what() const noexcept;
      |                         ^~~~
In file included from /usr/local/include/c++/12.1.0/bits/ios_base.h:44,
                 from /usr/local/include/c++/12.1.0/ios:42,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from N4910.h:2:
/usr/local/include/c++/12.1.0/stdexcept:143:5: note: overridden function is 'virtual const char* std::logic_error::what() const throw ()'
  143 |     what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW;
      |     ^~~~
p1739.cpp:77:34: error: expected ')' before 'e'
   77 | explicit future_error(future_errc e);
      |                      ~           ^~
      |                                  )
p1739.cpp:80:26: error: expected initializer before 'noexcept'
   80 | const char* what() const noexcept;
      |                          ^~~~~~~~
p1739.cpp:109:24: error: expected ')' before ',' token
  109 | promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept;
      |        ~               ^
      |                        )
p1739.cpp:109:62: error: expected ',' or '...' before '&&' token
  109 | promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept;
      |                                                              ^~
p1739.cpp:109:47: error: invalid constructor; you probably meant 'std::promise<R> (const std::promise<R>&)'
  109 | promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept;
      |                                               ^~~~~~~
p1739.cpp:109:68: error: expected ';' at end of member declaration
  109 | promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept;
      |                                                                    ^
      |                                                                     ;
p1739.cpp:109:70: error: 'noexcept' does not name a type
  109 | promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept;
      |                                                                      ^~~~~~~~
p1739.cpp:109:70: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:110:27: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  110 | promise(const promise&) = delete;
      |                           ^~~~~~
p1739.cpp:113:33: error: expected ',' or '...' before '&&' token
  113 |       promise& operator=(promise&& rhs) noexcept;
      |                                 ^~
p1739.cpp:113:39: error: expected ';' at end of member declaration
  113 |       promise& operator=(promise&& rhs) noexcept;
      |                                       ^
      |                                        ;
p1739.cpp:113:41: error: 'noexcept' does not name a type
  113 |       promise& operator=(promise&& rhs) noexcept;
      |                                         ^~~~~~~~
p1739.cpp:113:41: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:114:44: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  114 |       promise& operator=(const promise&) = delete;
      |                                            ^~~~~~
p1739.cpp:115:31: error: expected ';' at end of member declaration
  115 |       void swap(promise& other) noexcept;
      |                               ^
      |                                ;
p1739.cpp:115:33: error: 'noexcept' does not name a type
  115 |       void swap(promise& other) noexcept;
      |                                 ^~~~~~~~
p1739.cpp:115:33: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:117:7: error: 'future' does not name a type
  117 |       future<R> get_future();
      |       ^~~~~~
p1739.cpp:119:16: error: 'see' has not been declared
  119 | void set_value(see below);
      |                ^~~
p1739.cpp:120:20: error: 'exception_ptr' has not been declared
  120 | void set_exception(exception_ptr p);
      |                    ^~~~~~~~~~~~~
p1739.cpp:122:31: error: 'see' has not been declared
  122 | void set_value_at_thread_exit(see below);
      |                               ^~~
p1739.cpp:123:41: error: 'exception_ptr' has not been declared
  123 |       void set_exception_at_thread_exit(exception_ptr p);
      |                                         ^~~~~~~~~~~~~
p1739.cpp:126:14: error: 'uses_allocator' is not a class template
  126 |       struct uses_allocator<promise<R>, Alloc>;
      |              ^~~~~~~~~~~~~~
p1739.cpp:126:14: error: 'std::uses_allocator' is not a template
p1739.cpp:40:17: note: previous declaration here
   40 |          struct uses_allocator<promise<R>, Alloc>;
      |                 ^~~~~~~~~~~~~~
p1739.cpp:132:13: error: 'uses_allocator' is not a class template
  132 |      struct uses_allocator<promise<R>, Alloc>
      |             ^~~~~~~~~~~~~~
p1739.cpp:133:20: error: expected class-name before '{' token
  133 |        : true_type { };
      |                    ^
p1739.cpp:136:16: error: expected constructor, destructor, or type conversion before '(' token
  136 |         promise(allocator_arg_t, const Allocator& a);
      |                ^
p1739.cpp:138:8: error: expected constructor, destructor, or type conversion before '(' token
  138 | promise(promise&& rhs) noexcept;
      |        ^
p1739.cpp:140:9: error: expected class-name before '(' token
  140 | ~promise();
      |         ^
p1739.cpp:142:1: error: invalid use of template-name 'std::promise' without an argument list
  142 | promise& operator=(promise&& rhs) noexcept;
      | ^~~~~~~
p1739.cpp:142:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:144:6: error: variable or field 'swap' declared void
  144 | void swap(promise& other) noexcept;
      |      ^~~~
p1739.cpp:144:18: error: missing template arguments before '&' token
  144 | void swap(promise& other) noexcept;
      |                  ^
p1739.cpp:144:20: error: 'other' was not declared in this scope
  144 | void swap(promise& other) noexcept;
      |                    ^~~~~
p1739.cpp:147:1: error: 'future' does not name a type
  147 | future<R> get_future();
      | ^~~~~~
p1739.cpp:154:6: error: 'template<class R> class std::promise' used without template arguments
  154 | void promise::set_value(const R& r);
      |      ^~~~~~~
p1739.cpp:154:31: error: 'R' does not name a type
  154 | void promise::set_value(const R& r);
      |                               ^
p1739.cpp:155:6: error: 'template<class R> class std::promise' used without template arguments
  155 | void promise::set_value(R&& r);
      |      ^~~~~~~
p1739.cpp:155:6: error: variable or field 'set_value' declared void
p1739.cpp:155:25: error: 'R' was not declared in this scope
  155 | void promise::set_value(R&& r);
      |                         ^
p1739.cpp:155:29: error: 'r' was not declared in this scope
  155 | void promise::set_value(R&& r);
      |                             ^
p1739.cpp:156:14: error: 'R' was not declared in this scope
  156 | void promise<R&>::set_value(R& r);
      |              ^
p1739.cpp:156:16: error: template argument 1 is invalid
  156 | void promise<R&>::set_value(R& r);
      |                ^
p1739.cpp:156:6: error: variable or field 'set_value' declared void
  156 | void promise<R&>::set_value(R& r);
      |      ^~~~~~~~~~~
p1739.cpp:156:29: error: 'R' was not declared in this scope
  156 | void promise<R&>::set_value(R& r);
      |                             ^
p1739.cpp:156:32: error: 'r' was not declared in this scope
  156 | void promise<R&>::set_value(R& r);
      |                                ^
p1739.cpp:157:6: error: specializing member 'std::promise<void>::set_value' requires 'template<>' syntax
  157 | void promise<void>::set_value();
      |      ^~~~~~~~~~~~~
p1739.cpp:162:6: error: variable or field 'set_exception' declared void
  162 | void set_exception(exception_ptr p);
      |      ^~~~~~~~~~~~~
p1739.cpp:162:20: error: 'exception_ptr' was not declared in this scope
  162 | void set_exception(exception_ptr p);
      |                    ^~~~~~~~~~~~~
p1739.cpp:165:2: error: expected unqualified-id before numeric constant
  165 | (33.10.5).
      |  ^~~~~~~
p1739.cpp:165:2: error: expected ')' before numeric constant
  165 | (33.10.5).
      | ~^~~~~~~
      |  )
p1739.cpp:169:6: error: 'template<class R> class std::promise' used without template arguments
  169 | void promise::set_value_at_thread_exit(R&& r);
      |      ^~~~~~~
p1739.cpp:169:6: error: variable or field 'set_value_at_thread_exit' declared void
p1739.cpp:169:40: error: 'R' was not declared in this scope
  169 | void promise::set_value_at_thread_exit(R&& r);
      |                                        ^
p1739.cpp:169:44: error: 'r' was not declared in this scope
  169 | void promise::set_value_at_thread_exit(R&& r);
      |                                            ^
p1739.cpp:170:14: error: 'R' was not declared in this scope
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |              ^
p1739.cpp:170:16: error: template argument 1 is invalid
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |                ^
p1739.cpp:170:6: error: variable or field 'set_value_at_thread_exit' declared void
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |      ^~~~~~~~~~~
p1739.cpp:170:44: error: 'R' was not declared in this scope
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |                                            ^
p1739.cpp:170:47: error: 'r' was not declared in this scope
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |                                               ^
p1739.cpp:171:6: error: specializing member 'std::promise<void>::set_value_at_thread_exit' requires 'template<>' syntax
  171 | void promise<void>::set_value_at_thread_exit();
      |      ^~~~~~~~~~~~~
p1739.cpp:176:6: error: variable or field 'set_exception_at_thread_exit' declared void
  176 | void set_exception_at_thread_exit(exception_ptr p);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1739.cpp:176:35: error: 'exception_ptr' was not declared in this scope
  176 | void set_exception_at_thread_exit(exception_ptr p);
      |                                   ^~~~~~~~~~~~~
p1739.cpp:182:43: error: expected initializer before 'noexcept'
  182 |   void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                           ^~~~~~~~
p1739.cpp:194:15: error: expected ';' at end of member declaration
  194 |        future() noexcept;
      |               ^
      |                ;
p1739.cpp:194:17: error: 'noexcept' does not name a type
  194 |        future() noexcept;
      |                 ^~~~~~~~
p1739.cpp:194:17: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:195:21: error: expected ',' or '...' before '&&' token
  195 |        future(future&&) noexcept;
      |                     ^~
p1739.cpp:195:8: error: invalid constructor; you probably meant 'std::future<R> (const std::future<R>&)'
  195 |        future(future&&) noexcept;
      |        ^~~~~~
p1739.cpp:195:23: error: expected ';' at end of member declaration
  195 |        future(future&&) noexcept;
      |                       ^
      |                        ;
p1739.cpp:195:25: error: 'noexcept' does not name a type
  195 |        future(future&&) noexcept;
      |                         ^~~~~~~~
p1739.cpp:195:25: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:196:32: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  196 |        future(const future&) = delete;
      |                                ^~~~~~
p1739.cpp:199:36: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  199 | future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future<R> share() noexcept;
      |                                    ^~~~~~
p1739.cpp:199:68: error: expected ',' or '...' before '&&' token
  199 | future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future<R> share() noexcept;
      |                                                                    ^~
p1739.cpp:199:70: error: expected ';' at end of member declaration
  199 | future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future<R> share() noexcept;
      |                                                                      ^
      |                                                                       ;
p1739.cpp:199:72: error: 'noexcept' does not name a type
  199 | future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future<R> share() noexcept;
      |                                                                        ^~~~~~~~
p1739.cpp:199:72: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:199:82: error: 'shared_future' does not name a type
  199 | future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future<R> share() noexcept;
      |                                                                                  ^~~~~~~~~~~~~
p1739.cpp:201:1: error: 'see' does not name a type
  201 | see below get();
      | ^~~
p1739.cpp:203:23: error: expected ';' at end of member declaration
  203 |          bool valid() const noexcept;
      |                       ^~~~~
      |                            ;
p1739.cpp:203:29: error: 'noexcept' does not name a type
  203 |          bool valid() const noexcept;
      |                             ^~~~~~~~
p1739.cpp:203:29: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:206:41: error: 'chrono' does not name a type
  206 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                         ^~~~~~
p1739.cpp:206:57: error: expected unqualified-id before '<' token
  206 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                                         ^
p1739.cpp:206:57: error: expected ')' before '<' token
  206 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                  ~                      ^
      |                                                         )
p1739.cpp:206:57: error: expected initializer before '<' token
p1739.cpp:208:43: error: 'chrono' does not name a type
  208 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                           ^~~~~~
p1739.cpp:208:61: error: expected unqualified-id before '<' token
  208 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                             ^
p1739.cpp:208:61: error: expected ')' before '<' token
  208 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                    ~                        ^
      |                                                             )
p1739.cpp:208:61: error: expected initializer before '<' token
p1739.cpp:213:13: error: expected constructor, destructor, or type conversion before 'noexcept'
  213 |    future() noexcept;
      |             ^~~~~~~~
p1739.cpp:214:7: error: expected constructor, destructor, or type conversion before '(' token
  214 | future(future&& rhs) noexcept;
      |       ^
p1739.cpp:217:8: error: expected class-name before '(' token
  217 | ~future(); Effects:
      |        ^
p1739.cpp:217:19: error: found ':' in nested-name-specifier, expected '::'
  217 | ~future(); Effects:
      |                   ^
      |                   ::
p1739.cpp:217:12: error: 'Effects' does not name a type
  217 | ~future(); Effects:
      |            ^~~~~~~
p1739.cpp:223:1: error: 'shared_future' does not name a type
  223 | shared_future<R> share() noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:226:1: error: 'R' does not name a type
  226 | R future::get();
      | ^
p1739.cpp:227:1: error: 'R' does not name a type
  227 | R& future<R&>::get();
      | ^
p1739.cpp:228:12: error: specializing member 'std::future<void>::get' requires 'template<>' syntax
  228 |       void future<void>::get();
      |            ^~~~~~~~~~~~
p1739.cpp:239:30: error: 'chrono' does not name a type
  239 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                              ^~~~~~
p1739.cpp:239:46: error: expected unqualified-id before '<' token
  239 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                              ^
p1739.cpp:239:46: error: expected ')' before '<' token
  239 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                       ~                      ^
      |                                              )
p1739.cpp:239:46: error: expected initializer before '<' token
p1739.cpp:245:32: error: 'chrono' does not name a type
  245 | future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                ^~~~~~
p1739.cpp:245:50: error: expected unqualified-id before '<' token
  245 | future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                  ^
p1739.cpp:245:50: error: expected ')' before '<' token
  245 | future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                         ~                        ^
      |                                                  )
p1739.cpp:245:50: error: expected initializer before '<' token
p1739.cpp:260:15: error: expected ';' at end of member declaration
  260 | shared_future() noexcept;
      |               ^
      |                ;
p1739.cpp:260:17: error: 'noexcept' does not name a type
  260 | shared_future() noexcept;
      |                 ^~~~~~~~
p1739.cpp:260:17: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:261:39: error: expected ';' at end of member declaration
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                       ^
      |                                        ;
p1739.cpp:261:41: error: 'noexcept' does not name a type
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                         ^~~~~~~~
p1739.cpp:261:41: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:261:74: error: expected ',' or '...' before '&&' token
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                          ^~
p1739.cpp:261:76: error: expected ';' at end of member declaration
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                            ^
      |                                                                             ;
p1739.cpp:261:78: error: 'noexcept' does not name a type
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                              ^~~~~~~~
p1739.cpp:261:78: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:261:115: error: expected ',' or '...' before '&&' token
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                                                                   ^~
p1739.cpp:261:88: error: invalid constructor; you probably meant 'std::shared_future<R> (const std::shared_future<R>&)'
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                                        ^~~~~~~~~~~~~
p1739.cpp:261:121: error: expected ';' at end of member declaration
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                                                                         ^
      |                                                                                                                          ;
p1739.cpp:261:123: error: 'noexcept' does not name a type
  261 | shared_future(const shared_future& rhs) noexcept; shared_future(future<R>&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future();
      |                                                                                                                           ^~~~~~~~
p1739.cpp:261:123: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:262:50: error: expected ';' at end of member declaration
  262 | shared_future& operator=(const shared_future& rhs) noexcept; shared_future& operator=(shared_future&& rhs) noexcept;
      |                                                  ^
      |                                                   ;
p1739.cpp:262:52: error: 'noexcept' does not name a type
  262 | shared_future& operator=(const shared_future& rhs) noexcept; shared_future& operator=(shared_future&& rhs) noexcept;
      |                                                    ^~~~~~~~
p1739.cpp:262:52: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:262:100: error: expected ',' or '...' before '&&' token
  262 | shared_future& operator=(const shared_future& rhs) noexcept; shared_future& operator=(shared_future&& rhs) noexcept;
      |                                                                                                    ^~
p1739.cpp:262:106: error: expected ';' at end of member declaration
  262 | shared_future& operator=(const shared_future& rhs) noexcept; shared_future& operator=(shared_future&& rhs) noexcept;
      |                                                                                                          ^
      |                                                                                                           ;
p1739.cpp:262:108: error: 'noexcept' does not name a type
  262 | shared_future& operator=(const shared_future& rhs) noexcept; shared_future& operator=(shared_future&& rhs) noexcept;
      |                                                                                                            ^~~~~~~~
p1739.cpp:262:108: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:264:1: error: 'see' does not name a type
  264 | see below get() const; // functions to check state
      | ^~~
p1739.cpp:265:23: error: expected ';' at end of member declaration
  265 |          bool valid() const noexcept;
      |                       ^~~~~
      |                            ;
p1739.cpp:265:29: error: 'noexcept' does not name a type
  265 |          bool valid() const noexcept;
      |                             ^~~~~~~~
p1739.cpp:265:29: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1739.cpp:268:41: error: 'chrono' does not name a type
  268 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                         ^~~~~~
p1739.cpp:268:57: error: expected unqualified-id before '<' token
  268 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                                         ^
p1739.cpp:268:57: error: expected ')' before '<' token
  268 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                  ~                      ^
      |                                                         )
p1739.cpp:268:57: error: expected initializer before '<' token
p1739.cpp:270:43: error: 'chrono' does not name a type
  270 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                           ^~~~~~
p1739.cpp:270:61: error: expected unqualified-id before '<' token
  270 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                             ^
p1739.cpp:270:61: error: expected ')' before '<' token
  270 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                    ~                        ^
      |                                                             )
p1739.cpp:270:61: error: expected initializer before '<' token
p1739.cpp:275:20: error: expected constructor, destructor, or type conversion before 'noexcept'
  275 |    shared_future() noexcept;
      |                    ^~~~~~~~
p1739.cpp:276:21: error: invalid use of template-name 'std::shared_future' without an argument list
  276 | shared_future(const shared_future& rhs) noexcept;
      |                     ^~~~~~~~~~~~~
p1739.cpp:276:21: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:276:41: error: expected constructor, destructor, or type conversion before 'noexcept'
  276 | shared_future(const shared_future& rhs) noexcept;
      |                                         ^~~~~~~~
p1739.cpp:278:22: error: 'R' was not declared in this scope
  278 | shared_future(future<R>&& rhs) noexcept;
      |                      ^
p1739.cpp:278:23: error: template argument 1 is invalid
  278 | shared_future(future<R>&& rhs) noexcept;
      |                       ^
p1739.cpp:278:24: error: expected ',' or '...' before '&&' token
  278 | shared_future(future<R>&& rhs) noexcept;
      |                        ^~
p1739.cpp:278:32: error: expected constructor, destructor, or type conversion before 'noexcept'
  278 | shared_future(future<R>&& rhs) noexcept;
      |                                ^~~~~~~~
p1739.cpp:279:14: error: expected constructor, destructor, or type conversion before '(' token
  279 | shared_future(shared_future&& rhs) noexcept;
      |              ^
p1739.cpp:282:15: error: expected class-name before '(' token
  282 | ~shared_future(); Effects:
      |               ^
p1739.cpp:282:26: error: found ':' in nested-name-specifier, expected '::'
  282 | ~shared_future(); Effects:
      |                          ^
      |                          ::
p1739.cpp:282:19: error: 'Effects' does not name a type
  282 | ~shared_future(); Effects:
      |                   ^~~~~~~
p1739.cpp:288:1: error: invalid use of template-name 'std::shared_future' without an argument list
  288 | shared_future& operator=(const shared_future& rhs) noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:288:1: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:293:7: error: 'R' does not name a type
  293 | const R& shared_future::get() const;
      |       ^
p1739.cpp:294:1: error: 'R' does not name a type
  294 | R& shared_future<R&>::get() const;
      | ^
p1739.cpp:295:6: error: specializing member 'std::shared_future<void>::get' requires 'template<>' syntax
  295 | void shared_future<void>::get() const;
      |      ^~~~~~~~~~~~~~~~~~~
p1739.cpp:304:20: error: expected initializer before 'noexcept'
  304 | bool valid() const noexcept;
      |                    ^~~~~~~~
p1739.cpp:308:30: error: 'chrono' does not name a type
  308 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                              ^~~~~~
p1739.cpp:308:46: error: expected unqualified-id before '<' token
  308 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                              ^
p1739.cpp:308:46: error: expected ')' before '<' token
  308 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                       ~                      ^
      |                                              )
p1739.cpp:308:46: error: expected initializer before '<' token
p1739.cpp:315:34: error: 'chrono' does not name a type
  315 |   future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                  ^~~~~~
p1739.cpp:315:52: error: expected unqualified-id before '<' token
  315 |   future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                    ^
p1739.cpp:315:52: error: expected ')' before '<' token
  315 |   future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                           ~                        ^
      |                                                    )
p1739.cpp:315:52: error: expected initializer before '<' token
p1739.cpp:316:1: error: expected unqualified-id before '[' token
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      | ^
p1739.cpp:332:30: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  332 |       template<class F, class... Args>
      |                              ^~~
p1739.cpp:333:9: error: expected unqualified-id before '[' token
  333 |         [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |         ^
p1739.cpp:335:30: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  335 |       template<class F, class... Args>
      |                              ^~~
p1739.cpp:336:7: error: found ':' in nested-name-specifier, expected '::'
  336 | Throws: timeout-related exceptions (33.2.4).
      |       ^
      |       ::
p1739.cpp:336:1: error: 'Throws' does not name a type
  336 | Throws: timeout-related exceptions (33.2.4).
      | ^~~~~~
p1739.cpp: In function 'int work(int)':
p1739.cpp:350:1: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
  350 | auto handle = std::async([=]{ return work2(value); }); int tmp = work1(value);
      | ^~~~
      | ----
p1739.cpp:350:6: error: 'handle' does not name a type
  350 | auto handle = std::async([=]{ return work2(value); }); int tmp = work1(value);
      |      ^~~~~~
p1739.cpp:350:53: error: expected primary-expression before ')' token
  350 | auto handle = std::async([=]{ return work2(value); }); int tmp = work1(value);
      |                                                     ^
p1739.cpp:350:66: error: 'work1' was not declared in this scope; did you mean 'work2'?
  350 | auto handle = std::async([=]{ return work2(value); }); int tmp = work1(value);
      |                                                                  ^~~~~
      |                                                                  work2
p1739.cpp:351:14: error: 'handle' was not declared in this scope
  351 | return tmp + handle.get(); // #1
      |              ^~~~~~
p1739.cpp: At global scope:
p1739.cpp:359:25: error: 'std::packaged_task' is not a template
  359 |   template<class> class packaged_task;
      |                         ^~~~~~~~~~~~~
p1739.cpp:44:16: note: previous declaration here
   44 |          class packaged_task<R(ArgTypes...)>;
      |                ^~~~~~~~~~~~~
p1739.cpp:360:26: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  360 |   template<class R, class... ArgTypes>
      |                          ^~~
p1739.cpp:361:9: error: 'packaged_task' is not a class template
  361 |   class packaged_task<R(ArgTypes...)> {
      |         ^~~~~~~~~~~~~
p1739.cpp:361:33: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  361 |   class packaged_task<R(ArgTypes...)> {
      |                                 ^~~
p1739.cpp:361:37: error: 'std::packaged_task' is not a template
  361 |   class packaged_task<R(ArgTypes...)> {
      |                                     ^
p1739.cpp:44:16: note: previous declaration here
   44 |          class packaged_task<R(ArgTypes...)>;
      |                ^~~~~~~~~~~~~
p1739.cpp:383:34: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  383 |           template<class R, class... ArgTypes>
      |                                  ^~~
p1739.cpp:384:28: error: expected ')' before '(' token
  384 |             packaged_task(R (*)(ArgTypes...)) -> packaged_task<R(ArgTypes...)>;
      |                          ~ ^~
      |                            )
p1739.cpp:385:36: error: expected initializer before '->' token
  385 | template<class F> packaged_task(F) -> packaged_task<see below>; }
      |                                    ^~
p1739.cpp:387:21: error: expected unqualified-id before ')' token
  387 |       packaged_task() noexcept;
      |                     ^
p1739.cpp:390:16: error: expected ')' before '&&' token
  390 | packaged_task(F&& f);
      |              ~ ^~
      |                )
p1739.cpp:396:36: error: expected initializer before '->' token
  396 | template<class F> packaged_task(F) -> packaged_task<see below>;
      |                                    ^~
p1739.cpp:398:28: error: expected ')' before '&&' token
  398 | packaged_task(packaged_task&& rhs) noexcept;
      |              ~             ^~
      |                            )
p1739.cpp:401:39: error: expected ',' or '...' before '&&' token
  401 | packaged_task& operator=(packaged_task&& rhs) noexcept;
      |                                       ^~
p1739.cpp:401:47: error: expected initializer before 'noexcept'
  401 | packaged_task& operator=(packaged_task&& rhs) noexcept;
      |                                               ^~~~~~~~
p1739.cpp:404:17: error: expected constructor, destructor, or type conversion before ';' token
  404 | ~packaged_task();
      |                 ^
p1739.cpp:406:33: error: expected initializer before 'noexcept'
  406 | void swap(packaged_task& other) noexcept;
      |                                 ^~~~~~~~
p1739.cpp:409:20: error: expected initializer before 'noexcept'
  409 | bool valid() const noexcept;
      |                    ^~~~~~~~
p1739.cpp:416:6: error: declaration of 'operator()' as non-function
  416 | void operator()(ArgTypes... args);
      |      ^~~~~~~~
p1739.cpp:416:17: error: 'ArgTypes' was not declared in this scope
  416 | void operator()(ArgTypes... args);
      |                 ^~~~~~~~
p1739.cpp:420:6: error: variable or field 'make_ready_at_thread_exit' declared void
  420 | void make_ready_at_thread_exit(ArgTypes... args);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~
p1739.cpp:420:32: error: 'ArgTypes' was not declared in this scope
  420 | void make_ready_at_thread_exit(ArgTypes... args);
      |                                ^~~~~~~~
p1739.cpp:429:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  429 | template<class R, class... ArgTypes>
      |                        ^~~
p1739.cpp:430:11: error: 'std::packaged_task' is not a template
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |           ^~~~~~~~~~~~~
p1739.cpp:430:35: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |                                   ^~~
p1739.cpp:430:45: error: 'std::packaged_task' is not a template
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |                                             ^~~~~~~~~~~~~
p1739.cpp:430:69: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |                                                                     ^~~
p1739.cpp:430:79: error: expected initializer before 'noexcept'
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |                                                                               ^~~~~~~~

$ g++ p1739.cpp -std=2b -o p1739g -I. -Wall
p1739.cpp:165:2: error: too many decimal points in number
  165 | (33.10.5).
      |  ^~~~~~~
p1739.cpp:336:37: error: too many decimal points in number
  336 | Throws: timeout-related exceptions (33.2.4).
      |                                     ^~~~~~
p1739.cpp:24:18: error: 'implementation' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                  ^~~~~~~~~~~~~~
p1739.cpp:24:33: error: 'defined' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                 ^~~~~~~
p1739.cpp:24:69: error: 'implementation' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                     ^~~~~~~~~~~~~~
p1739.cpp:24:84: error: 'defined' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                    ^~~~~~~
p1739.cpp:24:121: error: 'implementation' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                         ^~~~~~~~~~~~~~
p1739.cpp:24:136: error: 'defined' was not declared in this scope
   24 | broken_promise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                                        ^~~~~~~
p1739.cpp:24:156: error: 'implementation' was not declared in this scope
   24 | mise = implementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                                                  ^~~~~~~~~~~~~~

p1739.cpp:24:171: error: 'defined' was not declared in this scope
   24 | ementation-defined, future_already_retrieved = implementation-defined, promise_already_satisfied = implementation-defined, no_state = implementation-defined
      |                                                                                                                                                      ^~~~~~~

p1739.cpp:26:6: warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
   26 | enum class launch : unspecified { async = unspecified,
      | ~~~~ ^~~~~
      |      -----
p1739.cpp:26:19: error: found ':' in nested-name-specifier, expected '::'
   26 | enum class launch : unspecified { async = unspecified,
      |                   ^
      |                   ::
p1739.cpp:26:12: error: 'launch' has not been declared
   26 | enum class launch : unspecified { async = unspecified,
      |            ^~~~~~
p1739.cpp:26:33: error: expected unqualified-id before '{' token
   26 | enum class launch : unspecified { async = unspecified,
      |                                 ^
p1739.cpp:38:15: error: variable or field 'swap' declared void
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |               ^~~~
p1739.cpp:38:20: error: 'promise' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                    ^~~~~~~
p1739.cpp:11:1: note: 'std::promise' is defined in header '<future>'; did you forget to '#include <future>'?
   10 | #include "N4910.h"
  +++ |+#include <future>
   11 | 
p1739.cpp:38:29: error: expected primary-expression before '>' token
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                             ^
p1739.cpp:38:32: error: 'x' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                ^
p1739.cpp:38:35: error: 'promise' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                   ^~~~~~~
p1739.cpp:38:35: note: 'std::promise' is defined in header '<future>'; did you forget to '#include <future>'?
p1739.cpp:38:44: error: expected primary-expression before '>' token
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                            ^
p1739.cpp:38:47: error: 'y' was not declared in this scope
   38 |          void swap(promise<R>& x, promise<R>& y) noexcept;
      |                                               ^
p1739.cpp:40:32: error: 'promise' was not declared in this scope
   40 |          struct uses_allocator<promise<R>, Alloc>;
      |                                ^~~~~~~
p1739.cpp:40:32: note: 'std::promise' is defined in header '<future>'; did you forget to '#include <future>'?
p1739.cpp:40:41: error: wrong number of template arguments (1, should be 2)
   40 |          struct uses_allocator<promise<R>, Alloc>;
      |                                         ^
In file included from /usr/local/include/c++/12.1.0/bits/stringfwd.h:40,
                 from /usr/local/include/c++/12.1.0/iosfwd:39,
                 from /usr/local/include/c++/12.1.0/ios:38,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from N4910.h:2,
                 from p1739.cpp:10:
/usr/local/include/c++/12.1.0/bits/memoryfwd.h:72:12: note: provided for 'template<class, class> struct std::uses_allocator'
   72 |     struct uses_allocator;
      |            ^~~~~~~~~~~~~~
p1739.cpp:44:16: error: 'packaged_task' is not a class template
   44 |          class packaged_task<R(ArgTypes...)>;
      |                ^~~~~~~~~~~~~
p1739.cpp:44:32: error: 'ArgTypes' was not declared in this scope
   44 |          class packaged_task<R(ArgTypes...)>;
      |                                ^~~~~~~~
p1739.cpp:44:30: error: 'R' was not declared in this scope
   44 |          class packaged_task<R(ArgTypes...)>;
      |                              ^
p1739.cpp:46:20: error: 'std::packaged_task' is not a template
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                    ^~~~~~~~~~~~~
p1739.cpp:46:52: error: 'std::packaged_task' is not a template
   46 |          void swap(packaged_task<R(ArgTypes...)>&, packaged_task<R(ArgTypes...)>&) noexcept;
      |                                                    ^~~~~~~~~~~~~
p1739.cpp:48:55: error: 'F' was not declared in this scope
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                       ^
p1739.cpp:48:56: error: template argument 1 is invalid
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                        ^
p1739.cpp:48:67: error: 'Args' was not declared in this scope
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                                   ^~~~
p1739.cpp:48:71: error: template argument 1 is invalid
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                                       ^
p1739.cpp:48:72: error: expected parameter pack before '...'
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                                        ^~~
p1739.cpp:48:72: error: template argument 1 is invalid
p1739.cpp:48:72: error: template argument 2 is invalid
p1739.cpp:48:24: error: 'future' does not name a type
   48 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                        ^~~~~~
p1739.cpp:51:24: error: 'future' does not name a type
   51 |          [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                        ^~~~~~
p1739.cpp:77:10: error: ISO C++ forbids declaration of 'future_error' with no type [-fpermissive]
   77 | explicit future_error(future_errc e);
      |          ^~~~~~~~~~~~
p1739.cpp:77:1: error: 'explicit' outside class declaration
   77 | explicit future_error(future_errc e);
      | ^~~~~~~~
p1739.cpp:80:26: error: non-member function 'const char* what()' cannot have cv-qualifier
   80 | const char* what() const noexcept;
      |                          ^~~~~~~~
p1739.cpp:117:7: error: 'future' does not name a type
  117 |       future<R> get_future();
      |       ^~~~~~
p1739.cpp:119:16: error: 'see' has not been declared
  119 | void set_value(see below);
      |                ^~~
p1739.cpp:122:31: error: 'see' has not been declared
  122 | void set_value_at_thread_exit(see below);
      |                               ^~~
p1739.cpp:136:9: error: deduction guide for 'std::promise<R>' must have trailing return type
  136 |         promise(allocator_arg_t, const Allocator& a);
      |         ^~~~~~~
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:138:9: error: template placeholder type 'promise<...auto...>' must be followed by a simple declarator-id
  138 | promise(promise&& rhs) noexcept;
      |         ^~~~~~~
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:138:1: error: deduction guide for 'std::promise<R>' must have trailing return type
  138 | promise(promise&& rhs) noexcept;
      | ^~~~~~~
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:140:9: error: expected class-name before '(' token
  140 | ~promise();
      |         ^
p1739.cpp:142:20: error: template placeholder type 'promise<...auto...>' must be followed by a simple declarator-id
  142 | promise& operator=(promise&& rhs) noexcept;
      |                    ^~~~~~~
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:142:1: error: deduced class type 'promise' in function return type
  142 | promise& operator=(promise&& rhs) noexcept;
      | ^~~~~~~
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:144:11: error: template placeholder type 'promise<...auto...>' must be followed by a simple declarator-id
  144 | void swap(promise& other) noexcept;
      |           ^~~~~~~
p1739.cpp:105:11: note: 'template<class R> class std::promise' declared here
  105 |     class promise {
      |           ^~~~~~~
p1739.cpp:147:8: error: 'R' was not declared in this scope
  147 | future<R> get_future();
      |        ^
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:8: error: 'R' was not declared in this scope
p1739.cpp:147:1: error: 'future' does not name a type
  147 | future<R> get_future();
      | ^~~~~~
p1739.cpp:154:6: error: 'template<class R> class std::promise' used without template arguments
  154 | void promise::set_value(const R& r);
      |      ^~~~~~~
p1739.cpp:154:31: error: 'R' does not name a type
  154 | void promise::set_value(const R& r);
      |                               ^
p1739.cpp:155:6: error: 'template<class R> class std::promise' used without template arguments
  155 | void promise::set_value(R&& r);
      |      ^~~~~~~
p1739.cpp:155:6: error: variable or field 'set_value' declared void
p1739.cpp:155:25: error: 'R' was not declared in this scope
  155 | void promise::set_value(R&& r);
      |                         ^
p1739.cpp:155:29: error: 'r' was not declared in this scope
  155 | void promise::set_value(R&& r);
      |                             ^
p1739.cpp:156:14: error: 'R' was not declared in this scope
  156 | void promise<R&>::set_value(R& r);
      |              ^
p1739.cpp:156:16: error: template argument 1 is invalid
  156 | void promise<R&>::set_value(R& r);
      |                ^
p1739.cpp:156:6: error: variable or field 'set_value' declared void
  156 | void promise<R&>::set_value(R& r);
      |      ^~~~~~~~~~~
p1739.cpp:156:29: error: 'R' was not declared in this scope
  156 | void promise<R&>::set_value(R& r);
      |                             ^
p1739.cpp:156:32: error: 'r' was not declared in this scope
  156 | void promise<R&>::set_value(R& r);
      |                                ^
p1739.cpp:157:6: error: specializing member 'std::promise<void>::set_value' requires 'template<>' syntax
  157 | void promise<void>::set_value();
      |      ^~~~~~~~~~~~~
p1739.cpp:165:2: error: expected unqualified-id before numeric constant
  165 | (33.10.5).
      |  ^~~~~~~
p1739.cpp:165:2: error: expected ')' before numeric constant
  165 | (33.10.5).
      | ~^~~~~~~
      |  )
p1739.cpp:169:6: error: 'template<class R> class std::promise' used without template arguments
  169 | void promise::set_value_at_thread_exit(R&& r);
      |      ^~~~~~~
p1739.cpp:169:6: error: variable or field 'set_value_at_thread_exit' declared void
p1739.cpp:169:40: error: 'R' was not declared in this scope
  169 | void promise::set_value_at_thread_exit(R&& r);
      |                                        ^
p1739.cpp:169:44: error: 'r' was not declared in this scope
  169 | void promise::set_value_at_thread_exit(R&& r);
      |                                            ^
p1739.cpp:170:14: error: 'R' was not declared in this scope
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |              ^
p1739.cpp:170:16: error: template argument 1 is invalid
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |                ^
p1739.cpp:170:6: error: variable or field 'set_value_at_thread_exit' declared void
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |      ^~~~~~~~~~~
p1739.cpp:170:44: error: 'R' was not declared in this scope
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |                                            ^
p1739.cpp:170:47: error: 'r' was not declared in this scope
  170 | void promise<R&>::set_value_at_thread_exit(R& r);
      |                                               ^
p1739.cpp:171:6: error: specializing member 'std::promise<void>::set_value_at_thread_exit' requires 'template<>' syntax
  171 | void promise<void>::set_value_at_thread_exit();
      |      ^~~~~~~~~~~~~
p1739.cpp:199:82: error: 'shared_future' does not name a type; did you mean 'shared_ptr'?
  199 | future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future<R> share() noexcept;
      |                                                                                  ^~~~~~~~~~~~~
      |                                                                                  shared_ptr
p1739.cpp:201:1: error: 'see' does not name a type
  201 | see below get();
      | ^~~
p1739.cpp:206:41: error: 'chrono' does not name a type
  206 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                         ^~~~~~
p1739.cpp:206:57: error: expected unqualified-id before '<' token
  206 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                                         ^
p1739.cpp:206:57: error: expected ')' before '<' token
  206 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                  ~                      ^
      |                                                         )
p1739.cpp:206:57: error: expected initializer before '<' token
p1739.cpp:208:43: error: 'chrono' does not name a type
  208 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                           ^~~~~~
p1739.cpp:208:61: error: expected unqualified-id before '<' token
  208 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                             ^
p1739.cpp:208:61: error: expected ')' before '<' token
  208 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                    ~                        ^
      |                                                             )
p1739.cpp:208:61: error: expected initializer before '<' token
p1739.cpp:213:4: error: deduction guide for 'std::future<R>' must have trailing return type
  213 |    future() noexcept;
      |    ^~~~~~
p1739.cpp:192:12: note: 'template<class R> class std::future' declared here
  192 |      class future {
      |            ^~~~~~
p1739.cpp:214:8: error: template placeholder type 'future<...auto...>' must be followed by a simple declarator-id
  214 | future(future&& rhs) noexcept;
      |        ^~~~~~
p1739.cpp:192:12: note: 'template<class R> class std::future' declared here
  192 |      class future {
      |            ^~~~~~
p1739.cpp:214:1: error: deduction guide for 'std::future<R>' must have trailing return type
  214 | future(future&& rhs) noexcept;
      | ^~~~~~
p1739.cpp:192:12: note: 'template<class R> class std::future' declared here
  192 |      class future {
      |            ^~~~~~
p1739.cpp:217:8: error: expected class-name before '(' token
  217 | ~future(); Effects:
      |        ^
p1739.cpp:217:19: error: found ':' in nested-name-specifier, expected '::'
  217 | ~future(); Effects:
      |                   ^
      |                   ::
p1739.cpp:217:12: error: 'Effects' does not name a type
  217 | ~future(); Effects:
      |            ^~~~~~~
p1739.cpp:223:15: error: 'R' was not declared in this scope
  223 | shared_future<R> share() noexcept;
      |               ^
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:15: error: 'R' was not declared in this scope
p1739.cpp:223:1: error: 'shared_future' does not name a type
  223 | shared_future<R> share() noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:226:1: error: 'R' does not name a type
  226 | R future::get();
      | ^
p1739.cpp:227:1: error: 'R' does not name a type
  227 | R& future<R&>::get();
      | ^
p1739.cpp:228:12: error: specializing member 'std::future<void>::get' requires 'template<>' syntax
  228 |       void future<void>::get();
      |            ^~~~~~~~~~~~
p1739.cpp:239:30: error: 'chrono' does not name a type
  239 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                              ^~~~~~
p1739.cpp:239:46: error: expected unqualified-id before '<' token
  239 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                              ^
p1739.cpp:239:46: error: expected ')' before '<' token
  239 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                       ~                      ^
      |                                              )
p1739.cpp:239:46: error: expected initializer before '<' token
p1739.cpp:245:32: error: 'chrono' does not name a type
  245 | future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                ^~~~~~
p1739.cpp:245:50: error: expected unqualified-id before '<' token
  245 | future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                  ^
p1739.cpp:245:50: error: expected ')' before '<' token
  245 | future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                         ~                        ^
      |                                                  )
p1739.cpp:245:50: error: expected initializer before '<' token
p1739.cpp:264:1: error: 'see' does not name a type
  264 | see below get() const; // functions to check state
      | ^~~
p1739.cpp:268:41: error: 'chrono' does not name a type
  268 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                         ^~~~~~
p1739.cpp:268:57: error: expected unqualified-id before '<' token
  268 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                                         ^
p1739.cpp:268:57: error: expected ')' before '<' token
  268 |            future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                  ~                      ^
      |                                                         )
p1739.cpp:268:57: error: expected initializer before '<' token
p1739.cpp:270:43: error: 'chrono' does not name a type
  270 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                           ^~~~~~
p1739.cpp:270:61: error: expected unqualified-id before '<' token
  270 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                             ^
p1739.cpp:270:61: error: expected ')' before '<' token
  270 |            future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                    ~                        ^
      |                                                             )
p1739.cpp:270:61: error: expected initializer before '<' token
p1739.cpp:275:4: error: deduction guide for 'std::shared_future<R>' must have trailing return type
  275 |    shared_future() noexcept;
      |    ^~~~~~~~~~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:276:15: error: template placeholder type 'const shared_future<...auto...>' must be followed by a simple declarator-id
  276 | shared_future(const shared_future& rhs) noexcept;
      |               ^~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:276:1: error: deduction guide for 'std::shared_future<R>' must have trailing return type
  276 | shared_future(const shared_future& rhs) noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:278:22: error: 'R' was not declared in this scope
  278 | shared_future(future<R>&& rhs) noexcept;
      |                      ^
p1739.cpp:278:23: error: template argument 1 is invalid
  278 | shared_future(future<R>&& rhs) noexcept;
      |                       ^
p1739.cpp:278:1: error: deduction guide for 'std::shared_future<R>' must have trailing return type
  278 | shared_future(future<R>&& rhs) noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:279:15: error: template placeholder type 'shared_future<...auto...>' must be followed by a simple declarator-id
  279 | shared_future(shared_future&& rhs) noexcept;
      |               ^~~~~~~~~~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:279:1: error: deduction guide for 'std::shared_future<R>' must have trailing return type
  279 | shared_future(shared_future&& rhs) noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:282:15: error: expected class-name before '(' token
  282 | ~shared_future(); Effects:
      |               ^
p1739.cpp:282:26: error: found ':' in nested-name-specifier, expected '::'
  282 | ~shared_future(); Effects:
      |                          ^
      |                          ::
p1739.cpp:282:19: error: 'Effects' does not name a type
  282 | ~shared_future(); Effects:
      |                   ^~~~~~~
p1739.cpp:288:26: error: template placeholder type 'const shared_future<...auto...>' must be followed by a simple declarator-id
  288 | shared_future& operator=(const shared_future& rhs) noexcept;
      |                          ^~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:288:1: error: deduced class type 'shared_future' in function return type
  288 | shared_future& operator=(const shared_future& rhs) noexcept;
      | ^~~~~~~~~~~~~
p1739.cpp:258:14: note: 'template<class R> class std::shared_future' declared here
  258 |        class shared_future {
      |              ^~~~~~~~~~~~~
p1739.cpp:293:7: error: 'R' does not name a type
  293 | const R& shared_future::get() const;
      |       ^
p1739.cpp:294:1: error: 'R' does not name a type
  294 | R& shared_future<R&>::get() const;
      | ^
p1739.cpp:295:6: error: specializing member 'std::shared_future<void>::get' requires 'template<>' syntax
  295 | void shared_future<void>::get() const;
      |      ^~~~~~~~~~~~~~~~~~~
p1739.cpp:304:20: error: non-member function 'bool valid()' cannot have cv-qualifier
  304 | bool valid() const noexcept;
      |                    ^~~~~~~~
p1739.cpp:308:30: error: 'chrono' does not name a type
  308 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                              ^~~~~~
p1739.cpp:308:46: error: expected unqualified-id before '<' token
  308 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                                              ^
p1739.cpp:308:46: error: expected ')' before '<' token
  308 | future_status wait_for(const chrono::duration<Rep, Period>& rel_time) const;
      |                       ~                      ^
      |                                              )
p1739.cpp:308:46: error: expected initializer before '<' token
p1739.cpp:315:34: error: 'chrono' does not name a type
  315 |   future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                  ^~~~~~
p1739.cpp:315:52: error: expected unqualified-id before '<' token
  315 |   future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                                                    ^
p1739.cpp:315:52: error: expected ')' before '<' token
  315 |   future_status wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
      |                           ~                        ^
      |                                                    )
p1739.cpp:315:52: error: expected initializer before '<' token
p1739.cpp:316:46: error: 'F' was not declared in this scope
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                              ^
p1739.cpp:316:47: error: template argument 1 is invalid
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                               ^
p1739.cpp:316:58: error: 'Args' was not declared in this scope
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                          ^~~~
p1739.cpp:316:62: error: template argument 1 is invalid
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                              ^
p1739.cpp:316:63: error: expected parameter pack before '...'
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                               ^~~
p1739.cpp:316:63: error: template argument 1 is invalid
p1739.cpp:316:63: error: template argument 2 is invalid
p1739.cpp:316:66: error: template argument 1 is invalid
  316 | [[nodiscard]] future<invoke_result_t<decay_t<F>, decay_t<Args>...>>
      |                                                                  ^~
p1739.cpp:317:9: warning: 'nodiscard' attribute can only be applied to functions or to class or enumeration types [-Wattributes]
  317 |   async(launch policy, F&& f, Args&&... args);
      |         ^~~~~~
p1739.cpp:317:9: error: 'launch' was not declared in this scope
p1739.cpp:317:24: error: 'F' was not declared in this scope
  317 |   async(launch policy, F&& f, Args&&... args);
      |                        ^
p1739.cpp:317:28: error: 'f' was not declared in this scope
  317 |   async(launch policy, F&& f, Args&&... args);
      |                            ^
p1739.cpp:317:31: error: 'Args' was not declared in this scope
  317 |   async(launch policy, F&& f, Args&&... args);
      |                               ^~~~
p1739.cpp:317:45: error: expression list treated as compound expression in initializer [-fpermissive]
  317 |   async(launch policy, F&& f, Args&&... args);
      |                                             ^
p1739.cpp:334:38: error: 'template<class F, class ... Args> std::future<typename std::invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Types>::type ...>::type> async(F&&, Args&& ...)' redeclared as different kind of entity
  334 |           async(F&& f, Args&&... args);
      |                                      ^
p1739.cpp:317:3: note: previous declaration 'int async'
  317 |   async(launch policy, F&& f, Args&&... args);
      |   ^~~~~
p1739.cpp:336:7: error: found ':' in nested-name-specifier, expected '::'
  336 | Throws: timeout-related exceptions (33.2.4).
      |       ^
      |       ::
p1739.cpp:336:1: error: 'Throws' does not name a type
  336 | Throws: timeout-related exceptions (33.2.4).
      | ^~~~~~
p1739.cpp: In function 'int work(int)':
p1739.cpp:350:20: error: 'async' is not a member of 'std'
  350 | auto handle = std::async([=]{ return work2(value); }); int tmp = work1(value);
      |                    ^~~~~
p1739.cpp:350:20: note: 'std::async' is defined in header '<future>'; did you forget to '#include <future>'?
p1739.cpp:350:66: error: 'work1' was not declared in this scope; did you mean 'work2'?
  350 | auto handle = std::async([=]{ return work2(value); }); int tmp = work1(value);
      |                                                                  ^~~~~
      |                                                                  work2
p1739.cpp: At global scope:
p1739.cpp:359:25: error: 'std::packaged_task' is not a template
  359 |   template<class> class packaged_task;
      |                         ^~~~~~~~~~~~~
p1739.cpp:44:16: note: previous declaration here
   44 |          class packaged_task<R(ArgTypes...)>;
      |                ^~~~~~~~~~~~~
p1739.cpp:361:9: error: 'packaged_task' is not a class template
  361 |   class packaged_task<R(ArgTypes...)> {
      |         ^~~~~~~~~~~~~
p1739.cpp:361:37: error: 'std::packaged_task' is not a template
  361 |   class packaged_task<R(ArgTypes...)> {
      |                                     ^
p1739.cpp:44:16: note: previous declaration here
   44 |          class packaged_task<R(ArgTypes...)>;
      |                ^~~~~~~~~~~~~
p1739.cpp:384:50: error: 'std::packaged_task' is not a template
  384 |             packaged_task(R (*)(ArgTypes...)) -> packaged_task<R(ArgTypes...)>;
      |                                                  ^~~~~~~~~~~~~
p1739.cpp:384:79: error: expected constructor, destructor, or type conversion before ';' token
  384 |             packaged_task(R (*)(ArgTypes...)) -> packaged_task<R(ArgTypes...)>;
      |                                                                               ^
p1739.cpp:385:39: error: 'std::packaged_task' is not a template
  385 | template<class F> packaged_task(F) -> packaged_task<see below>; }
      |                                       ^~~~~~~~~~~~~
p1739.cpp:385:53: error: 'see' was not declared in this scope
  385 | template<class F> packaged_task(F) -> packaged_task<see below>; }
      |                                                     ^~~
p1739.cpp:385:57: error: expected '>' before 'below'
  385 | template<class F> packaged_task(F) -> packaged_task<see below>; }
      |                                                         ^~~~~
p1739.cpp:385:63: error: expected constructor, destructor, or type conversion before ';' token
  385 | template<class F> packaged_task(F) -> packaged_task<see below>; }
      |                                                               ^
p1739.cpp:387:31: error: expected constructor, destructor, or type conversion before ';' token
  387 |       packaged_task() noexcept;
      |                               ^
p1739.cpp:390:21: error: expected constructor, destructor, or type conversion before ';' token
  390 | packaged_task(F&& f);
      |                     ^
p1739.cpp:396:39: error: 'std::packaged_task' is not a template
  396 | template<class F> packaged_task(F) -> packaged_task<see below>;
      |                                       ^~~~~~~~~~~~~
p1739.cpp:396:53: error: 'see' was not declared in this scope
  396 | template<class F> packaged_task(F) -> packaged_task<see below>;
      |                                                     ^~~
p1739.cpp:396:57: error: expected '>' before 'below'
  396 | template<class F> packaged_task(F) -> packaged_task<see below>;
      |                                                         ^~~~~
p1739.cpp:396:63: error: expected constructor, destructor, or type conversion before ';' token
  396 | template<class F> packaged_task(F) -> packaged_task<see below>;
      |                                                               ^
p1739.cpp:398:44: error: expected constructor, destructor, or type conversion before ';' token
  398 | packaged_task(packaged_task&& rhs) noexcept;
      |                                            ^
p1739.cpp:401:16: error: 'std::packaged_task& operator=(std::packaged_task&&)' must be a non-static member function
  401 | packaged_task& operator=(packaged_task&& rhs) noexcept;
      |                ^~~~~~~~
p1739.cpp:404:17: error: expected constructor, destructor, or type conversion before ';' token
  404 | ~packaged_task();
      |                 ^
p1739.cpp:409:20: error: non-member function 'bool valid()' cannot have cv-qualifier
  409 | bool valid() const noexcept;
      |                    ^~~~~~~~
p1739.cpp:416:6: error: declaration of 'operator()' as non-function
  416 | void operator()(ArgTypes... args);
      |      ^~~~~~~~
p1739.cpp:416:17: error: 'ArgTypes' was not declared in this scope
  416 | void operator()(ArgTypes... args);
      |                 ^~~~~~~~
p1739.cpp:420:6: error: variable or field 'make_ready_at_thread_exit' declared void
  420 | void make_ready_at_thread_exit(ArgTypes... args);
      |      ^~~~~~~~~~~~~~~~~~~~~~~~~
p1739.cpp:420:32: error: 'ArgTypes' was not declared in this scope
  420 | void make_ready_at_thread_exit(ArgTypes... args);
      |                                ^~~~~~~~
p1739.cpp:430:11: error: 'std::packaged_task' is not a template
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |           ^~~~~~~~~~~~~
p1739.cpp:430:45: error: 'std::packaged_task' is not a template
  430 | void swap(packaged_task<R(ArgTypes...)>& x, packaged_task<R(ArgTypes...)>& y) noexcept;
      |                                             ^~~~~~~~~~~~~

```

# 検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。

<!-- リンクエラーの解説をする。clang++とg++の比較。意味のある出力。
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。-->

## 応用例1　AUTOSAR C++

AUTOSARでC++のコーディング標準を作っている。　
MISRA-C++コーディング標準の改訂をまたずに、C++14に対応したかったためかもしれない。　

Autosar Guidelines C++14 example code compile list

https://qiita.com/kaizen_nagoya/items/8ccbf6675c3494d57a76

MISRA C++, AUTOSAR C++について

https://qiita.com/kaizen_nagoya/items/3436fbd49865e0da7d35

## 応用例2　MISRA C/C++

MISRA C まとめ #include <misra_c.h>

https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9

MISRA C++ 5-0-16

https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74

## 応用例3 CERT C/C++

SEI CERT C++ Coding Standard AA. Bibliography 確認中。

https://qiita.com/kaizen_nagoya/items/fe06719aef10f3f985ae

MISRA C/C++, AUTOSAR C++, CERT C/C++とC/C++工業標準をコンパイルする

https://qiita.com/kaizen_nagoya/items/8dff19511e42b2593db1

## 応用例4 箱庭　
 箱庭もくもく会 

https://hakoniwa.connpass.com

第11回 未定

箱庭ではUnityをはじめC++を使っているらしい。　

ここでコンパイルしたコードと同じようなコードを使っているか、
ここで出たコンパイルエラーと同じようなエラーがでたかを
いろいろな版のコンパイラでコンパイルして確認していく。

この項目は、箱庭プロジェクトを市場分析の対象として、原則的には、箱庭プロジェクトの外部から分析し、外部から箱庭の広告宣伝のための戦略会議を仮想した結果、仮想「箱庭もくもく会」を開催してみることを企画するものである。　
一切の内容は、箱庭プロジェクト、Athrill, TOPPERSとは無関係である。　
一(いち)参加データアナリストの、個人的なつぶやきです。

仮想戦略会議「箱庭」

https://qiita.com/kaizen_nagoya/items/73cb132707653176a461

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる（１）

https://qiita.com/kaizen_nagoya/items/a22bf2b1dab0ad3258d4

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる（2）

https://qiita.com/kaizen_nagoya/items/e3c0ceb2dcc9cf3f3fac


## 自己参考資料(self reference)

関連する自己参照以外は、こちらの先頭に移転。

C言語（C++)に対する誤解、曲解、無理解、爽快。

https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

#include "N4910.h"

https://qiita.com/kaizen_nagoya/items/163a47cef7d6bb1c33a8

C++N4910資料の改善点

https://qiita.com/kaizen_nagoya/items/fb4ceb5d117a54641af3

dockerにclang

https://qiita.com/kaizen_nagoya/items/8829ffeee397eda50e80

docker gnu(gcc/g++) and llvm(clang/clang++)

https://qiita.com/kaizen_nagoya/items/059874ea39c4de64c0f7

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)

https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

C++N4910:2022 tag follower 300人超えました。ありがとうございます。

https://qiita.com/kaizen_nagoya/items/a63fb96d351ac5c16ff7

astyle 使ってみた

https://qiita.com/kaizen_nagoya/items/3c9a87a781d53a1a23f3

 ＜この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。＞

# 文書履歴(document history)
ver. 0.01 初稿 　20221009