33.3 Stop tokens thread.stoptoken C++N4910:2022 (709) p1663.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.3 Stop tokens thread.stoptoken C++N4910:2022 (709) p1663.cpp

## 算譜(source code)

```c++:p1663.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.3 Stop tokens thread.stoptoken C++N4910:2022 (709) p1663.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;

// 33.3.1 Introduction [thread.stoptoken.intro]
// Subclause 33.3 describes components that can be used to asynchronously request that an operation stops execution in a timely manner, typically because the result is no longer required. Such a request is called a stop request.
// stop_source, stop_token, and stop_callback implement semantics of shared ownership of a stop state. Any stop_source, stop_token, or stop_callback that shares ownership of the same stop state is an associated stop_source, stop_token, or stop_callback, respectively. The last remaining owner of the stop state automatically releases the resources associated with the stop state.
//  A stop_token can be passed to an operation which can either
// — actively poll the token to check if there has been a stop request, or
// — register a callback using the stop_callback class template which will be called in the event that a stop request is made.
// A stop request made via a stop_source will be visible to all associated stop_token and stop_source objects. Once a stop request has been made it cannot be withdrawn (a subsequent stop request has no effect).
//  Callbacks registered via a stop_callback object are called when a stop request is first made by any associated stop_source object.
//  Calls to the functions request_stop, stop_requested, and stop_possible do not introduce data races. A call to request_stop that returns true synchronizes with a call to stop_requested on an associated stop_token or stop_source object that returns true. Registration of a callback synchronizes with the invocation of that callback.
// 33.3.2 Header <stop_token> synopsis
namespace std {
// 33.3.3, class stop_token class stop_token;
// 33.3.4, class stop_source class stop_source;
// no-shared-stop-state indicator
struct nostopstate_t {
    explicit nostopstate_t() = default;
};
inline constexpr nostopstate_t nostopstate{};
// 33.3.5, class stop_callback
template<class Callback> class stop_callback;
}
// [thread.stoptoken.syn]
// 33.3.3 Class stop_token [stoptoken]
// 33.3.3.1 General [stoptoken.general]
//  The class stop_token provides an interface for querying whether a stop request has been made (stop_- requested) or can ever be made (stop_possible) using an associated stop_source object (33.3.4). A stop_token can also be passed to a stop_callback (33.3.5) constructor to register a callback to be called when a stop request has been made from an associated stop_source.
namespace std {
class stop_token {
public:
// 33.3.3.2, constructors, copy, and assignment
    stop_token() noexcept;
    stop_token(const stop_token&) noexcept;
    stop_token(stop_token&&) noexcept;
    stop_token& operator=(const stop_token&) noexcept;
    stop_token& operator=(stop_token&&) noexcept;
    ~stop_token();
    void swap(stop_token&) noexcept;
// 33.3.3.3, stop handling
    [[nodiscard]] bool stop_requested() const noexcept;
    [[nodiscard]] bool stop_possible() const noexcept;
    [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
    friend void swap(stop_token& lhs, stop_token& rhs) noexcept;
};
}
// 33.3.3.2 Constructors, copy, and assignment [stoptoken.cons]
stop_token() noexcept;
// Postconditions: stop_possible() is false and stop_requested() is false.
// [Note 1: Because the created stop_token object can never receive a stop request, no resources are allocated for a stop state.
stop_token(const stop_token& rhs) noexcept;
// Postconditions: *this == rhs is true.
// [Note 2: *this and rhs share the ownership of the same stop state, if any.
stop_token(stop_token&& rhs) noexcept;
// Postconditions: *this contains the value of rhs prior to the start of construction and rhs.stop_- possible() is false.
~stop_token();
// Effects: Releases ownership of the stop state, if any.
stop_token& operator=(const stop_token& rhs) noexcept;
// Effects: Equivalent to: stop_token(rhs).swap(*this). Returns: *this.
stop_token& operator=(stop_token&& rhs) noexcept;
// Effects: Equivalent to: stop_token(std::move(rhs)).swap(*this). Returns: *this.
void swap(stop_token& rhs) noexcept;
// Effects: Exchanges the values of *this and rhs. 33.3.3.3 Members
[[nodiscard]] bool stop_requested() const noexcept;
[stoptoken.mem]
// Returns: true if *this has ownership of a stop state that has received a stop request; otherwise, false.
[[nodiscard]] bool stop_possible() const noexcept;
// Returns: false if:
// — *this does not have ownership of a stop state, or
// — a stop request was not made and there are no associated stop_source objects;
// otherwise, true.
// 33.3.3.4 Non-member functions [stoptoken.nonmembers]
[[nodiscard]] bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
// Returns: true if lhs and rhs have ownership of the same stop state or if both lhs and rhs do not have ownership of a stop state; otherwise false.
friend void swap(stop_token& x, stop_token& y) noexcept;
// Effects: Equivalent to: x.swap(y).
// 33.3.4 Class stop_source [stopsource]
// 33.3.4.1 General [stopsource.general]
//  The class stop_source implements the semantics of making a stop request. A stop request made on a stop_source object is visible to all associated stop_source and stop_token (33.3.3) objects. Once a stop request has been made it cannot be withdrawn (a subsequent stop request has no effect).
namespace std {
// no-shared-stop-state indicator
struct nostopstate_t {
    explicit nostopstate_t() = default;
};
inline constexpr nostopstate_t nostopstate{};
// Effects: Initialises *this to have ownership of a new stop state.
// Postconditions: stop_possible() is true and stop_requested() is false.
// Throws: bad_alloc if memory cannot be allocated for the stop state.
class stop_source {
public:
// 33.3.4.2, constructors, copy, and assignment stop_source();
    explicit stop_source(nostopstate_t) noexcept;
    stop_source(const stop_source&) noexcept;
    stop_source(stop_source&&) noexcept;
    stop_source& operator=(const stop_source&) noexcept;
    stop_source& operator=(stop_source&&) noexcept;
    ~stop_source();
    void swap(stop_source&) noexcept;
// 33.3.4.3, stop handling
    [[nodiscard]] stop_token get_token() const noexcept;
    [[nodiscard]] bool stop_possible() const noexcept;
    [[nodiscard]] bool stop_requested() const noexcept;
    bool request_stop() noexcept;
    [[nodiscard]] friend bool
    operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
    friend void swap(stop_source& lhs, stop_source& rhs) noexcept;
};
}
// 33.3.4.2 Constructors, copy, and assignment [stopsource.cons]
stop_source();
explicit stop_source(nostopstate_t) noexcept;
// Postconditions: stop_possible() is false and stop_requested() is false.
// [Note 1: No resources are allocated for the state.
stop_source(const stop_source& rhs) noexcept;
// Postconditions: *this == rhs is true.
// [Note 2: *this and rhs share the ownership of the same stop state, if any.
stop_source(stop_source&& rhs) noexcept;
// Postconditions: *this contains the value of rhs prior to the start of construction and rhs.stop_- possible() is false.
~stop_source();
// Effects: Releases ownership of the stop state, if any.
stop_source& operator=(const stop_source& rhs) noexcept;
// Effects: Equivalent to: stop_source(rhs).swap(*this). Returns: *this.
stop_source& operator=(stop_source&& rhs) noexcept;
// Effects: Equivalent to: stop_source(std::move(rhs)).swap(*this). Returns: *this.
void swap(stop_source& rhs) noexcept;
// Effects: Exchanges the values of *this and rhs.
// 33.3.4.3 Members [stopsource.mem]
[[nodiscard]] stop_token get_token() const noexcept;
// Returns: stop_token() if stop_possible() is false; otherwise a new associated stop_token object.
[[nodiscard]] bool stop_possible() const noexcept;
// Returns: true if *this has ownership of a stop state; otherwise, false.
[[nodiscard]] bool stop_requested() const noexcept;
// Returns: true if *this has ownership of a stop state that has received a stop request; otherwise, false.
bool request_stop() noexcept;
// Effects: If *this does not have ownership of a stop state, returns false. Otherwise, atomically determines whether the owned stop state has received a stop request, and if not, makes a stop request. The determination and making of the stop request are an atomic read-modify-write operation (6.9.2.2). If the request was made, the callbacks registered by associated stop_callback objects are synchronously called. If an invocation of a callback exits via an exception then terminate is invoked (14.6.2).
// [Note 1: A stop request includes notifying all condition variables of type condition_variable_any temporarily registered during an interruptible wait (33.7.5.3).
// Postconditions: stop_possible() is false or stop_requested() is true. Returns: true if this call made a stop request; otherwise false.
// 33.3.4.4 Non-member functions [stopsource.nonmembers]
[[nodiscard]] friend bool
operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
// Returns: true if lhs and rhs have ownership of the same stop state or if both lhs and rhs do not have ownership of a stop state; otherwise false.
friend void swap(stop_source& x, stop_source& y) noexcept;
// Effects: Equivalent to: x.swap(y).
// 33.3.5 Class template stop_callback [stopcallback]
// 33.3.5.1 General [stopcallback.general]
namespace std {
template<class Callback>
class stop_callback {
public:
    using callback_type = Callback;
// 33.3.5.2, constructors and destructor
    template<class C>
    explicit stop_callback(const stop_token& st, C&& cb)
    noexcept(is_nothrow_constructible_v<Callback, C>);
    template<class C>
    explicit stop_callback(stop_token&& st, C&& cb)
    noexcept(is_nothrow_constructible_v<Callback, C>);
    ~stop_callback();
    stop_callback(const stop_callback&) = delete;
    stop_callback(stop_callback&&) = delete;
    stop_callback& operator=(const stop_callback&) = delete;
    stop_callback& operator=(stop_callback&&) = delete;
private:
    Callback callback; // exposition only
};
template<class Callback>
stop_callback(stop_token, Callback) -> stop_callback<Callback>;
}
//  Mandates: stop_callback is instantiated with an argument for the template parameter Callback that satisfies both invocable and destructible.
// Preconditions: stop_callback is instantiated with an argument for the template parameter Callback that models both invocable and destructible.
// 33.3.5.2 Constructors and destructor [stopcallback.cons]
template<class C>
explicit stop_callback(const stop_token& st, C&& cb)
noexcept(is_nothrow_constructible_v<Callback, C>);
template<class C>
explicit stop_callback(stop_token&& st, C&& cb)
noexcept(is_nothrow_constructible_v<Callback, C>);
// Constraints: Callback and C satisfy constructible_from<Callback, C>.
// Preconditions: Callback and C model constructible_from<Callback, C>.
// Effects: Initializes callback with std::forward<C>(cb). If st.stop_requested() is true, then std::forward<Callback>(callback)() is evaluated in the current thread before the constructor returns. Otherwise, if st has ownership of a stop state, acquires shared ownership of that stop state and registers the callback with that stop state such that std::forward<Callback>(callback)() is evaluated by the first call to request_stop() on an associated stop_source.
// Throws: Any exception thrown by the initialization of callback.
// Remarks: If evaluating std::forward<Callback>(callback)() exits via an exception, then terminate
//  33.4 describes components that can be used to create and manage threads.
// [Note 1: These threads are intended to map one-to-one with operating system threads.
// 3.4.2 Header <thread> synopsis [thread.syn]
#include <compare> // see 17.11.1
namespace std {
// 33.4.3, class thread class thread;
void swap(thread& x, thread& y) noexcept;
// 33.4.4, class jthread class jthread;
// 33.4.5, namespace this_thread namespace this_thread {
thread::id get_id() noexcept;
// is invoked (14.6.2).
~stop_callback();
// Effects: Unregisters the callback from the owned stop state, if any. The destructor does not block waiting for the execution of another callback registered by an associated stop_callback. If callback is concurrently executing on another thread, then the return from the invocation of callback strongly happens before (6.9.2.2) callback is destroyed. If callback is executing on the current thread, then the destructor does not block (3.7) waiting for the return from the invocation of callback. Releases ownership of the stop state, if any.
// 33.4 Threads [thread.threads]
// 33.4.1 General [thread.threads.general]
void yield() noexcept;
template<class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
template<class Rep, class Period>
void sleep_for(const chrono::duration<Rep, Period>& rel_time);
}
}
// 33.4.3 Class thread [thread.thread.class]
// 33.4.3.1 General [thread.thread.class.general]
//  The class thread provides a mechanism to create a new thread of execution, to join with a thread (i.e., wait for a thread to complete), and to perform other operations that manage and query the state of a thread. A thread object uniquely represents a particular thread of execution. That representation may be transferred to other thread objects in such a way that no two thread objects simultaneously represent the same thread of execution. A thread of execution is detached when no thread object represents that thread. Objects of class thread can be in a state that does not represent a thread of execution.
// [Note 1: A thread object does not represent a thread of execution after default construction, after being moved from, or after a successful call to detach or join.
namespace std {
class thread {
public:
// 33.4.3.2, class thread::id
    class id;
    using native_handle_type = implementation-defined;
// construct/copy/destroy
// see 33.2.3
    thread() noexcept;
    template<class F, class... Args> explicit thread(F&& f, Args&&... args);
    ~thread();
    thread(const thread&) = delete;
    thread(thread&&) noexcept;
    thread& operator=(const thread&) = delete;
    thread& operator=(thread&&) noexcept;
// 33.4.3.6, members
    void swap(thread&) noexcept;
    bool joinable() const noexcept;
    void join();
    void detach();
    id get_id() const noexcept;
    native_handle_type native_handle();
// static members
    static unsigned int hardware_concurrency() noexcept;
};
}
// see 33.2.3
// 33.4.3.2 Class thread::id [thread.thread.id]
namespace std {
class thread::id {
public:
    id() noexcept;
};
bool operator==(thread::id x, thread::id y) noexcept;
strong_ordering operator<=>(thread::id x, thread::id y) noexcept;
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& out, thread::id id);
// hash support
template<class T> struct hash;
template<> struct hash<thread::id>;
}
// An object of type thread::id provides a unique identifier for each thread of execution and a single distinct value for all thread objects that do not represent a thread of execution (33.4.3). Each thread of execution has an associated thread::id object that is not equal to the thread::id object of any other thread of execution and that is not equal to the thread::id object of any thread object that does not represent threads of execution.
// thread::id is a trivially copyable class (11.2). The library may reuse the value of a thread::id of a terminated thread that can no longer be joined.
//  [Note 1: Relational operators allow thread::id objects to be used as keys in associative containers.
id() noexcept;
// Postconditions: The constructed object does not represent a thread of execution.
bool operator==(thread::id x, thread::id y) noexcept;
// Returns: true only if x and y represent the same thread of execution or neither x nor y represents a thread of execution.
strong_ordering operator<=>(thread::id x, thread::id y) noexcept;
// Let P(x,y) be an unspecified total ordering over thread::id as described in 27.8.
// Returns: strong_ordering::less if P (x, y) is true. Otherwise, strong_ordering::greater if P (y, x) is true. Otherwise, strong_ordering::equal.
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<< (basic_ostream<charT, traits>& out, thread::id id);
// Effects: Inserts an unspecified text representation of id into out. For two objects of type thread::id x and y, if x == y the thread::id objects have the same text representation and if x != y the thread::id objects have distinct text representations.
// Returns: out.
template<> struct hash<thread::id>;
// The specialization is enabled (22.10.19).
// 33.4.3.3 Constructors [thread.thread.constr]
thread() noexcept;
// Effects: The object does not represent a thread of execution.
// Postconditions: get_id() == id().
template<class F, class... Args> explicit thread(F&& f, Args&&... args);
// Constraints: remove_cvref_t<F> is not the same type as thread. 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 new thread of execution executes invoke(auto(std::forward<F>(f)), auto(std::forward<Args>(args))...) with the values produced by auto being materialized (7.3.5) in the constructing thread. Any return value from this invocation is ignored.
// [Note 1: This implies that any exceptions not thrown from the invocation of the copy of f will be thrown in the constructing thread, not the new thread.
// Effects: If joinable(), invokes terminate (14.6.2). Otherwise, has no effects.
// [Note 1: Either implicitly detaching or joining a joinable() thread in its destructor can result in difficult to debug correctness (for detach) or performance (for join) bugs encountered only when an exception is thrown. These bugs can be avoided by ensuring that the destructor is never executed while the thread is still joinable.
~thread();
// If the invocation of invoke terminates with an uncaught exception, terminate is invoked (14.6.2). Synchronization: The completion of the invocation of the constructor synchronizes with the beginning of the invocation of the copy of f.
// Postconditions: get_id() != id(). *this represents the newly started thread. Throws: system_error if unable to start the new thread.
// rror conditions:
// — resource_unavailable_try_again — the system lacked the necessary resources to create another thread, or the system-imposed limit on the number of threads in a process would be exceeded.
thread(thread&& x) noexcept;
// Postconditions: x.get_id() == id() and get_id() returns the value of x.get_id() prior to the start of construction.
// 33.4.3.4 Destructor [thread.thread.destr]
// 33.4.3.5 Assignment [thread.thread.assign]
thread& operator=(thread&& x) noexcept;
// Effects: If joinable(), invokes terminate (14.6.2). Otherwise, assigns the state of x to *this and sets x to a default constructed state.
// Postconditions: x.get_id() == id() and get_id() returns the value of x.get_id() prior to the assignment.
// Returns: *this.
// 33.4.3.6 Members [thread.thread.member]
void swap(thread& x) noexcept;
// Effects: Swaps the state of *this and x.
bool joinable() const noexcept;
// Returns: get_id() != id().
void join();
// Effects: Blocks until the thread represented by *this has completed.
// Synchronization: The completion of the thread represented by *this synchronizes with (6.9.2) the corresponding successful join() return.
// [Note 1: Operations on *this are not synchronized. —end note]
// Postconditions: The thread represented by *this has completed. get_id() == id(). Throws: system_error when an exception is required (33.2.2).
// Error conditions:
// — resource_deadlock_would_occur — if deadlock is detected or get_id() == this_thread:: get_id().
// — no_such_process — if the thread is not valid.
// — invalid_argument — if the thread is not joinable.
void detach();
// Effects: The thread represented by *this continues execution without the calling thread blocking. When detach() returns, *this no longer represents the possibly continuing thread of execution. When the thread previously represented by *this ends execution, the implementation releases any owned resources.
// Postconditions: get_id() == id().
// Throws: system_error when an exception is required (33.2.2). Error conditions:
// — no_such_process — if the thread is not valid.
// — invalid_argument — if the thread is not joinable.
id get_id() const noexcept;
// Returns: A default constructed id object if *this does not represent a thread, otherwise this_- thread::get_id() for the thread of execution represented by *this.
// 33.4.3.7 Static members [thread.thread.static]
unsigned hardware_concurrency() noexcept;
// Returns: The number of hardware thread contexts.
// [Note 1: This value should only be considered to be a hint. —end note]
// If this value is not computable or well-defined, an implementation should return 0.
// 33.4.3.8 Specialized algorithms [thread.thread.algorithm]
void swap(thread& x, thread& y) noexcept;
// Effects: As if by x.swap(y).
// 33.4.4 Class jthread [thread.jthread.class]
// 33.4.4.1 General [thread.jthread.class.general]
//  The class jthread provides a mechanism to create a new thread of execution. The functionality is the same as for class thread (33.4.3) with the additional abilities to provide a stop_token (33.3) to the new thread of execution, make stop requests, and automatically join.
namespace std {
class jthread {
public:
// types
    using id = thread::id;
    using native_handle_type = thread::native_handle_type;
// 33.4.4.2, constructors, move, and assignment
    jthread() noexcept;
    template<class F, class... Args> explicit jthread(F&& f, Args&&... args);
    ~jthread();
    jthread(const jthread&) = delete;
    jthread(jthread&&) noexcept;
    jthread& operator=(const jthread&) = delete;
    jthread& operator=(jthread&&) noexcept;
// 33.4.4.3, members
    void swap(jthread&) noexcept;
    [[nodiscard]] bool joinable() const noexcept;
    void join();
    void detach();
    [[nodiscard]] id get_id() const noexcept;
    [[nodiscard]] native_handle_type native_handle();
// see 33.2.3
// Effects: Constructs a jthread object that does not represent a thread of execution. Postconditions: get_id() == id() is true and ssource.stop_possible() is false.
// Constraints: remove_cvref_t<F> is not the same type as jthread. 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>...> || is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>.
// Effects: Initializes ssource. The new thread of execution executes invoke(auto(std::forward<F>(f)), get_stop_token(),
    auto(std::forward<Args>(args))...)
    if that expression is well-formed, otherwise
    invoke(auto(std::forward<F>(f)), auto(std::forward<Args>(args))...)
// with the values produced by auto being materialized (7.3.5) in the constructing thread. Any return value from this invocation is ignored.
// [Note 1: This implies that any exceptions not thrown from the invocation of the copy of f will be thrown in the constructing thread, not the new thread.
// If the invoke expression exits via an exception, terminate is called.
// Synchronization: The completion of the invocation of the constructor synchronizes with the beginning of the invocation of the copy of f.
// Postconditions: get_id() != id() is true and ssource.stop_possible() is true and *this repre-sents the newly started thread.
// [Note 2: The calling thread can make a stop request only once, because it cannot replace this stop token.
// Throws: system_error if unable to start the new thread. Error conditions:
// — resource_unavailable_try_again — the system lacked the necessary resources to create another thread, or the system-imposed limit on the number of threads in a process would be exceeded.
// 33.4.4.4, stop token handling
        [[nodiscard]] stop_source get_stop_source() noexcept;
        [[nodiscard]] stop_token get_stop_token() const noexcept;
        bool request_stop() noexcept;
// 33.4.4.5, specialized algorithms
        friend void swap(jthread& lhs, jthread& rhs) noexcept;
// 33.4.4.6, static members
        [[nodiscard]] static unsigned int hardware_concurrency() noexcept;
        private:
            stop_source ssource; // exposition only
        };
}
// 3.4.4.2 Constructors, move, and assignment [thread.jthread.cons]
jthread() noexcept;
template<class F, class... Args> explicit jthread(F&& f, Args&&... args);
jthread(jthread&& x) noexcept;
// Postconditions: x.get_id() == id() and get_id() returns the value of x.get_id() prior to the start of construction. ssource has the value of x.ssource prior to the start of construction and x.ssource.stop_possible() is false.
~jthread();
// Effects: If joinable() is true, calls request_stop() and then join().
// [Note 3: Operations on *this are not synchronized.
jthread& operator=(jthread&& x) noexcept;
// Effects: If joinable() is true, calls request_stop() and then join(). Assigns the state of x to *this and sets x to a default constructed state.
// Postconditions: x.get_id() == id() and get_id() returns the value of x.get_id() prior to the assignment. ssource has the value of x.ssource prior to the assignment and x.ssource.stop_- possible() is false.
// Returns: *this.
// 33.4.4.3 Members [thread.jthread.mem]
void swap(jthread& x) noexcept;
// Effects: Exchanges the values of *this and x.
[[nodiscard]] bool joinable() const noexcept;
// Returns: get_id() != id().
void join();
// Effects: Blocks until the thread represented by *this has completed.
// Synchronization: The completion of the thread represented by *this synchronizes with (6.9.2) the corresponding successful join() return.
// [Note 1: Operations on *this are not synchronized.
// Postconditions: The thread represented by *this has completed. get_id() == id(). Throws: system_error when an exception is required (33.2.2).
// Error conditions:
// — resource_deadlock_would_occur — if deadlock is detected or get_id() == this_thread:: get_id().
// — no_such_process — if the thread is not valid.
// — invalid_argument — if the thread is not joinable.
void detach();
// Effects: The thread represented by *this continues execution without the calling thread blocking. When detach() returns, *this no longer represents the possibly continuing thread of execution. When the thread previously represented by *this ends execution, the implementation releases any owned resources.
// Postconditions: get_id() == id().
// Throws: system_error when an exception is required (33.2.2). Error conditions:
// — no_such_process — if the thread is not valid.
// — invalid_argument — if the thread is not joinable.
id get_id() const noexcept;
// Returns: A default constructed id object if *this does not represent a thread, otherwise this_- thread::get_id() for the thread of execution represented by *this.
// 33.4.4.4 Stop token handling [thread.jthread.stop]
[[nodiscard]] stop_source get_stop_source() noexcept;
// Effects: Equivalent to: return ssource;
[[nodiscard]] stop_token get_stop_token() const noexcept;
// Effects: Equivalent to:
return ssource.get_token();
bool request_stop() noexcept;
//Returns: An object of type thread::id that uniquely identifies the current thread of execution. No other thread of execution has this id and this thread of execution always has this id. The object returned does not compare equal to a default constructed thread::id.
// Effects: Equivalent to:
return ssource.request_stop();
// 33.4.4.5 Specialized algorithms
friend void swap(jthread& x, jthread& y) noexcept;
// [thread.jthread.special]
// [thread.jthread.static]
// [thread.thread.this]
// Effects: Equivalent to: x.swap(y).
// 33.4.4.6 Static members
[[nodiscard]] static unsigned int hardware_concurrency() noexcept;
// Returns: thread::hardware_concurrency(). 33.4.5 Namespace this_thread
namespace std::this_thread {
thread::id get_id() noexcept;
void yield() noexcept;
template<class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
template<class Rep, class Period>
void sleep_for(const chrono::duration<Rep, Period>& rel_time);
}
thread::id this_thread::get_id() noexcept;
void this_thread::yield() noexcept;
// Effects: Offers the implementation the opportunity to reschedule. // // Synchronization: None.
template<class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
// Effects: Blocks the calling thread for the absolute timeout (33.2.4) specified by abs_time. Synchronization: None.
// Throws: Timeout-related exceptions (33.2.4).
template<class Rep, class Period>
void sleep_for(const chrono::duration<Rep, Period>& rel_time);
// Effects: Blocks the calling thread for the relative timeout (33.2.4) specified by rel_time. Synchronization: None.
// Throws: Timeout-related exceptions (33.2.4).
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
```

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

```ubuntu:bash
$ clang++ p1663.cpp -std=03 -o p1663l -I. -Wall
In file included from p1663.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 \
 ^
p1663.cpp:29:34: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
      explicit nostopstate_t() = default;
                                 ^
p1663.cpp:31:12: error: unknown type name 'constexpr'
    inline constexpr nostopstate_t nostopstate{};
           ^
p1663.cpp:31:5: warning: inline variables are a C++17 extension [-Wc++17-extensions]
    inline constexpr nostopstate_t nostopstate{};
    ^
p1663.cpp:31:35: error: expected ';' after top level declarator
    inline constexpr nostopstate_t nostopstate{};
                                  ^
                                  ;
p1663.cpp:43:13: error: expected ';' at end of declaration list
stop_token() noexcept;
            ^
            ;
p1663.cpp:44:30: error: expected ';' at end of declaration list
stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
                             ^
                             ;
p1663.cpp:44:62: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
                                                             ^
p1663.cpp:44:65: error: expected ';' at end of declaration list
stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
                                                                ^
                                                                ;
p1663.cpp:45:41: error: expected ';' at end of declaration list
stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
                                        ^
                                        ;
p1663.cpp:45:84: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
                                                                                   ^
p1663.cpp:45:87: error: expected ';' at end of declaration list
stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
                                                                                      ^
                                                                                      ;
p1663.cpp:46:32: error: expected ';' at end of declaration list
         void swap(stop_token&) noexcept;
                               ^
                               ;
p1663.cpp:48:2: error: expected expression
[[nodiscard]] bool stop_requested() const noexcept; [[nodiscard]] bool stop_possible() const noexcept;
 ^
p1663.cpp:48:15: error: expected member name or ';' after declaration specifiers
[[nodiscard]] bool stop_requested() const noexcept; [[nodiscard]] bool stop_possible() const noexcept;
              ^
p1663.cpp:48:54: error: expected expression
[[nodiscard]] bool stop_requested() const noexcept; [[nodiscard]] bool stop_possible() const noexcept;
                                                     ^
p1663.cpp:48:67: error: expected member name or ';' after declaration specifiers
[[nodiscard]] bool stop_requested() const noexcept; [[nodiscard]] bool stop_possible() const noexcept;
                                                                  ^
p1663.cpp:49:11: error: expected expression
         [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
          ^
p1663.cpp:49:24: error: expected member name or ';' after declaration specifiers
         [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
                       ^
p1663.cpp:50:60: error: expected ';' at end of declaration list
         friend void swap(stop_token& lhs, stop_token& rhs) noexcept;
                                                           ^
                                                           ;
p1663.cpp:54:15: error: expected unqualified-id
   stop_token() noexcept;
              ^
p1663.cpp:57:12: error: expected unqualified-id
stop_token(const stop_token& rhs) noexcept;
           ^
p1663.cpp:57:12: error: expected ')'
p1663.cpp:57:11: note: to match this '('
stop_token(const stop_token& rhs) noexcept;
          ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 warnings and 20 errors generated.
$ clang++ p1663.cpp -std=2b -o p1663l -I. -Wall
p1663.cpp:49:10: error: an attribute list cannot appear here
         [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
         ^~~~~~~~~~~~~
p1663.cpp:54:15: error: expected unqualified-id
   stop_token() noexcept;
              ^
p1663.cpp:57:12: error: expected unqualified-id
stop_token(const stop_token& rhs) noexcept;
           ^
p1663.cpp:57:12: error: expected ')'
p1663.cpp:57:11: note: to match this '('
stop_token(const stop_token& rhs) noexcept;
          ^
p1663.cpp:60:22: error: expected ')'
stop_token(stop_token&& rhs) noexcept;
                     ^
p1663.cpp:60:11: note: to match this '('
stop_token(stop_token&& rhs) noexcept;
          ^
p1663.cpp:60:29: error: expected ';' after top level declarator
stop_token(stop_token&& rhs) noexcept;
                            ^
                            ;
p1663.cpp:62:1: error: destructor must be a non-static member function
~stop_token();
^
p1663.cpp:64:1: error: reference to 'stop_token' is ambiguous
stop_token& operator=(const stop_token& rhs) noexcept;
^
p1663.cpp:60:12: note: candidate found by name lookup is 'stop_token'
stop_token(stop_token&& rhs) noexcept;
           ^
p1663.cpp:40:14: note: candidate found by name lookup is 'std::stop_token'
       class stop_token {
             ^
p1663.cpp:64:29: error: reference to 'stop_token' is ambiguous
stop_token& operator=(const stop_token& rhs) noexcept;
                            ^
p1663.cpp:60:12: note: candidate found by name lookup is 'stop_token'
stop_token(stop_token&& rhs) noexcept;
           ^
p1663.cpp:40:14: note: candidate found by name lookup is 'std::stop_token'
       class stop_token {
             ^
p1663.cpp:64:13: error: overloaded 'operator=' must be a binary operator (has 1 parameter)
stop_token& operator=(const stop_token& rhs) noexcept;
            ^
p1663.cpp:66:1: error: reference to 'stop_token' is ambiguous
stop_token& operator=(stop_token&& rhs) noexcept;
^
p1663.cpp:60:12: note: candidate found by name lookup is 'stop_token'
stop_token(stop_token&& rhs) noexcept;
           ^
p1663.cpp:40:14: note: candidate found by name lookup is 'std::stop_token'
       class stop_token {
             ^
p1663.cpp:66:23: error: reference to 'stop_token' is ambiguous
stop_token& operator=(stop_token&& rhs) noexcept;
                      ^
p1663.cpp:60:12: note: candidate found by name lookup is 'stop_token'
stop_token(stop_token&& rhs) noexcept;
           ^
p1663.cpp:40:14: note: candidate found by name lookup is 'std::stop_token'
       class stop_token {
             ^
p1663.cpp:66:13: error: overloaded 'operator=' must be a binary operator (has 1 parameter)
stop_token& operator=(stop_token&& rhs) noexcept;
            ^
p1663.cpp:68:11: error: reference to 'stop_token' is ambiguous
void swap(stop_token& rhs) noexcept;
          ^
p1663.cpp:60:12: note: candidate found by name lookup is 'stop_token'
stop_token(stop_token&& rhs) noexcept;
           ^
p1663.cpp:40:14: note: candidate found by name lookup is 'std::stop_token'
       class stop_token {
             ^
p1663.cpp:68:11: error: reference to 'stop_token' is ambiguous
void swap(stop_token& rhs) noexcept;
          ^
p1663.cpp:60:12: note: candidate found by name lookup is 'stop_token'
stop_token(stop_token&& rhs) noexcept;
           ^
p1663.cpp:40:14: note: candidate found by name lookup is 'std::stop_token'
       class stop_token {
             ^
p1663.cpp:70:37: error: non-member function cannot have 'const' qualifier
[[nodiscard]] bool stop_requested() const noexcept;
                                    ^~~~~~
p1663.cpp:71:2: error: use of undeclared identifier 'stoptoken'
[stoptoken.mem]
 ^
p1663.cpp:73:1: error: an attribute list cannot appear here
[[nodiscard]] bool stop_possible() const noexcept;
^~~~~~~~~~~~~
p1663.cpp:73:15: error: expected unqualified-id
[[nodiscard]] bool stop_possible() const noexcept;
              ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1663.cpp -std=03 -o p1663g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1663.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 \
      |  ^~~~~
p1663.cpp:31:12: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   31 |     inline constexpr nostopstate_t nostopstate{};
      |            ^~~~~~~~~
p1663.cpp:43:14: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   43 | stop_token() noexcept;
      |              ^~~~~~~~
p1663.cpp:29:34: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   29 |       explicit nostopstate_t() = default;
      |                                  ^~~~~~~
p1663.cpp:31:12: error: 'constexpr' does not name a type
   31 |     inline constexpr nostopstate_t nostopstate{};
      |            ^~~~~~~~~
p1663.cpp:31:12: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:43:12: error: expected ';' at end of member declaration
   43 | stop_token() noexcept;
      |            ^
      |             ;
p1663.cpp:43:14: error: 'noexcept' does not name a type
   43 | stop_token() noexcept;
      |              ^~~~~~~~
p1663.cpp:43:14: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:44:29: error: expected ';' at end of member declaration
   44 | stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
      |                             ^
      |                              ;
p1663.cpp:44:31: error: 'noexcept' does not name a type
   44 | stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
      |                               ^~~~~~~~
p1663.cpp:44:31: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:44:62: error: expected ',' or '...' before '&&' token
   44 | stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
      |                                                              ^~
p1663.cpp:44:41: error: invalid constructor; you probably meant 'std::stop_token (const std::stop_token&)'
   44 | stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
      |                                         ^~~~~~~~~~
p1663.cpp:44:64: error: expected ';' at end of member declaration
   44 | stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
      |                                                                ^
      |                                                                 ;
p1663.cpp:44:66: error: 'noexcept' does not name a type
   44 | stop_token(const stop_token&) noexcept; stop_token(stop_token&&) noexcept;
      |                                                                  ^~~~~~~~
p1663.cpp:44:66: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:45:40: error: expected ';' at end of member declaration
   45 | stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
      |                                        ^
      |                                         ;
p1663.cpp:45:42: error: 'noexcept' does not name a type
   45 | stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
      |                                          ^~~~~~~~
p1663.cpp:45:42: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:45:84: error: expected ',' or '...' before '&&' token
   45 | stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
      |                                                                                    ^~
p1663.cpp:45:86: error: expected ';' at end of member declaration
   45 | stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
      |                                                                                      ^
      |                                                                                       ;
p1663.cpp:45:88: error: 'noexcept' does not name a type
   45 | stop_token& operator=(const stop_token&) noexcept; stop_token& operator=(stop_token&&) noexcept; ~stop_token();
      |                                                                                        ^~~~~~~~
p1663.cpp:45:88: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:46:31: error: expected ';' at end of member declaration
   46 |          void swap(stop_token&) noexcept;
      |                               ^
      |                                ;
p1663.cpp:46:33: error: 'noexcept' does not name a type
   46 |          void swap(stop_token&) noexcept;
      |                                 ^~~~~~~~
p1663.cpp:46:33: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:48:1: error: expected unqualified-id before '[' token
   48 | [[nodiscard]] bool stop_requested() const noexcept; [[nodiscard]] bool stop_possible() const noexcept;
      | ^
p1663.cpp:48:53: error: expected unqualified-id before '[' token
   48 | [[nodiscard]] bool stop_requested() const noexcept; [[nodiscard]] bool stop_possible() const noexcept;
      |                                                     ^
p1663.cpp:49:10: error: expected unqualified-id before '[' token
   49 |          [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
      |          ^
p1663.cpp:50:59: error: expected ';' at end of member declaration
   50 |          friend void swap(stop_token& lhs, stop_token& rhs) noexcept;
      |                                                           ^
      |                                                            ;
p1663.cpp:50:61: error: 'noexcept' does not name a type
   50 |          friend void swap(stop_token& lhs, stop_token& rhs) noexcept;
      |                                                             ^~~~~~~~
p1663.cpp:50:61: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:54:15: error: expected unqualified-id before ')' token
   54 |    stop_token() noexcept;
      |               ^
p1663.cpp:57:12: error: expected unqualified-id before 'const'
   57 | stop_token(const stop_token& rhs) noexcept;
      |            ^~~~~
p1663.cpp:57:12: error: expected ')' before 'const'
   57 | stop_token(const stop_token& rhs) noexcept;
      |           ~^~~~~
      |            )
p1663.cpp:60:22: error: expected ')' before '&&' token
   60 | stop_token(stop_token&& rhs) noexcept;
      |           ~          ^~
      |                      )
p1663.cpp:62:14: error: expected constructor, destructor, or type conversion before ';' token
   62 | ~stop_token();
      |              ^
p1663.cpp:64:46: error: expected initializer before 'noexcept'
   64 | stop_token& operator=(const stop_token& rhs) noexcept;
      |                                              ^~~~~~~~
p1663.cpp:66:33: error: expected ',' or '...' before '&&' token
   66 | stop_token& operator=(stop_token&& rhs) noexcept;
      |                                 ^~
p1663.cpp:66:41: error: expected initializer before 'noexcept'
   66 | stop_token& operator=(stop_token&& rhs) noexcept;
      |                                         ^~~~~~~~
p1663.cpp:68:28: error: expected initializer before 'noexcept'
   68 | void swap(stop_token& rhs) noexcept;
      |                            ^~~~~~~~
p1663.cpp:70:1: error: expected unqualified-id before '[' token
   70 | [[nodiscard]] bool stop_requested() const noexcept;
      | ^
p1663.cpp:71:1: error: expected unqualified-id before '[' token
   71 | [stoptoken.mem]
      | ^
p1663.cpp:79:1: error: expected unqualified-id before '[' token
   79 | [[nodiscard]] bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
      | ^
p1663.cpp:81:1: error: 'friend' used outside of class
   81 | friend void swap(stop_token& x, stop_token& y) noexcept;
      | ^~~~~~
      | ------
p1663.cpp:81:48: error: expected initializer before 'noexcept'
   81 | friend void swap(stop_token& x, stop_token& y) noexcept;
      |                                                ^~~~~~~~
p1663.cpp:88:15: error: redefinition of 'struct std::nostopstate_t'
   88 |        struct nostopstate_t {
      |               ^~~~~~~~~~~~~
p1663.cpp:28:12: note: previous definition of 'struct std::nostopstate_t'
   28 |     struct nostopstate_t {
      |            ^~~~~~~~~~~~~
p1663.cpp:91:15: error: 'constexpr' does not name a type
   91 |        inline constexpr nostopstate_t nostopstate{};
      |               ^~~~~~~~~
p1663.cpp:91:15: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:98:35: error: expected ';' at end of member declaration
   98 | explicit stop_source(nostopstate_t) noexcept;
      |                                   ^
      |                                    ;
p1663.cpp:98:37: error: 'noexcept' does not name a type
   98 | explicit stop_source(nostopstate_t) noexcept;
      |                                     ^~~~~~~~
p1663.cpp:98:37: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:99:31: error: expected ';' at end of member declaration
   99 | stop_source(const stop_source&) noexcept; stop_source(stop_source&&) noexcept;
      |                               ^
      |                                ;
p1663.cpp:99:33: error: 'noexcept' does not name a type
   99 | stop_source(const stop_source&) noexcept; stop_source(stop_source&&) noexcept;
      |                                 ^~~~~~~~
p1663.cpp:99:33: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:99:66: error: expected ',' or '...' before '&&' token
   99 | stop_source(const stop_source&) noexcept; stop_source(stop_source&&) noexcept;
      |                                                                  ^~
p1663.cpp:99:43: error: invalid constructor; you probably meant 'std::stop_source (const std::stop_source&)'
   99 | stop_source(const stop_source&) noexcept; stop_source(stop_source&&) noexcept;
      |                                           ^~~~~~~~~~~
p1663.cpp:99:68: error: expected ';' at end of member declaration
   99 | stop_source(const stop_source&) noexcept; stop_source(stop_source&&) noexcept;
      |                                                                    ^
      |                                                                     ;
p1663.cpp:99:70: error: 'noexcept' does not name a type
   99 | stop_source(const stop_source&) noexcept; stop_source(stop_source&&) noexcept;
      |                                                                      ^~~~~~~~
p1663.cpp:99:70: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:100:42: error: expected ';' at end of member declaration
  100 | stop_source& operator=(const stop_source&) noexcept; stop_source& operator=(stop_source&&) noexcept; ~stop_source();
      |                                          ^
      |                                           ;
p1663.cpp:100:44: error: 'noexcept' does not name a type
  100 | stop_source& operator=(const stop_source&) noexcept; stop_source& operator=(stop_source&&) noexcept; ~stop_source();
      |                                            ^~~~~~~~
p1663.cpp:100:44: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:100:88: error: expected ',' or '...' before '&&' token
  100 | stop_source& operator=(const stop_source&) noexcept; stop_source& operator=(stop_source&&) noexcept; ~stop_source();
      |                                                                                        ^~
p1663.cpp:100:90: error: expected ';' at end of member declaration
  100 | stop_source& operator=(const stop_source&) noexcept; stop_source& operator=(stop_source&&) noexcept; ~stop_source();
      |                                                                                          ^
      |                                                                                           ;
p1663.cpp:100:92: error: 'noexcept' does not name a type
  100 | stop_source& operator=(const stop_source&) noexcept; stop_source& operator=(stop_source&&) noexcept; ~stop_source();
      |                                                                                            ^~~~~~~~
p1663.cpp:100:92: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:101:27: error: expected ';' at end of member declaration
  101 |     void swap(stop_source&) noexcept;
      |                           ^
      |                            ;
p1663.cpp:101:29: error: 'noexcept' does not name a type
  101 |     void swap(stop_source&) noexcept;
      |                             ^~~~~~~~
p1663.cpp:101:29: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:103:1: error: expected unqualified-id before '[' token
  103 | [[nodiscard]] stop_token get_token() const noexcept; [[nodiscard]] bool stop_possible() const noexcept; [[nodiscard]] bool stop_requested() const noexcept; bool request_stop() noexcept;
      | ^
p1663.cpp:103:54: error: expected unqualified-id before '[' token
  103 | [[nodiscard]] stop_token get_token() const noexcept; [[nodiscard]] bool stop_possible() const noexcept; [[nodiscard]] bool stop_requested() const noexcept; bool request_stop() noexcept;
      |                                                      ^
p1663.cpp:103:105: error: expected unqualified-id before '[' token
  103 | [[nodiscard]] stop_token get_token() const noexcept; [[nodiscard]] bool stop_possible() const noexcept; [[nodiscard]] bool stop_requested() const noexcept; bool request_stop() noexcept;
      |                                                                                                         ^
p1663.cpp:103:175: error: expected ';' at end of member declaration
  103 | iscard]] stop_token get_token() const noexcept; [[nodiscard]] bool stop_possible() const noexcept; [[nodiscard]] bool stop_requested() const noexcept; bool request_stop() noexcept;
      |                                                                                                                                                                          ^
      |                                                                                                                                                                           ;
p1663.cpp:103:177: error: 'noexcept' does not name a type
  103 | iscard]] stop_token get_token() const noexcept; [[nodiscard]] bool stop_possible() const noexcept; [[nodiscard]] bool stop_requested() const noexcept; bool request_stop() noexcept;
      |                                                                                                                                                                            ^~~~~~~~

p1663.cpp:103:177: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:104:5: error: expected unqualified-id before '[' token
  104 |     [[nodiscard]] friend bool
      |     ^
p1663.cpp:106:56: error: expected ';' at end of member declaration
  106 |     friend void swap(stop_source& lhs, stop_source& rhs) noexcept;
      |                                                        ^
      |                                                         ;
p1663.cpp:106:58: error: 'noexcept' does not name a type
  106 |     friend void swap(stop_source& lhs, stop_source& rhs) noexcept;
      |                                                          ^~~~~~~~
p1663.cpp:106:58: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1663.cpp:110:13: error: expected unqualified-id before ')' token
  110 | stop_source();
      |             ^
p1663.cpp:111:37: error: expected initializer before 'noexcept'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |                                     ^~~~~~~~
p1663.cpp:114:13: error: expected unqualified-id before 'const'
  114 | stop_source(const stop_source& rhs) noexcept;
      |             ^~~~~
p1663.cpp:114:13: error: expected ')' before 'const'
  114 | stop_source(const stop_source& rhs) noexcept;
      |            ~^~~~~
      |             )
p1663.cpp:117:24: error: expected ')' before '&&' token
  117 | stop_source(stop_source&& rhs) noexcept;
      |            ~           ^~
      |                        )
p1663.cpp:119:15: error: expected constructor, destructor, or type conversion before ';' token
  119 | ~stop_source();
      |               ^
p1663.cpp:121:48: error: expected initializer before 'noexcept'
  121 | stop_source& operator=(const stop_source& rhs) noexcept;
      |                                                ^~~~~~~~
p1663.cpp:123:35: error: expected ',' or '...' before '&&' token
  123 | stop_source& operator=(stop_source&& rhs) noexcept;
      |                                   ^~
p1663.cpp:123:43: error: expected initializer before 'noexcept'
  123 | stop_source& operator=(stop_source&& rhs) noexcept;
      |                                           ^~~~~~~~
p1663.cpp:125:29: error: expected initializer before 'noexcept'
  125 | void swap(stop_source& rhs) noexcept;
      |                             ^~~~~~~~
p1663.cpp:128:1: error: expected unqualified-id before '[' token
  128 | [[nodiscard]] stop_token get_token() const noexcept;
      | ^
p1663.cpp:130:1: error: expected unqualified-id before '[' token
  130 | [[nodiscard]] bool stop_possible() const noexcept;
      | ^
p1663.cpp:132:1: error: expected unqualified-id before '[' token
  132 | [[nodiscard]] bool stop_requested() const noexcept;
      | ^
p1663.cpp:134:21: error: expected initializer before 'noexcept'
  134 | bool request_stop() noexcept;
      |                     ^~~~~~~~
p1663.cpp:139:1: error: expected unqualified-id before '[' token
  139 | [[nodiscard]] friend bool
      | ^
p1663.cpp:142:1: error: 'friend' used outside of class
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      | ^~~~~~
      | ------
p1663.cpp:142:50: error: expected initializer before 'noexcept'
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      |                                                  ^~~~~~~~
p1663.cpp:150:13: error: expected nested-name-specifier before 'callback_type'
  150 |       using callback_type = Callback;
      |             ^~~~~~~~~~~~~
p1663.cpp:153:55: error: expected ',' or '...' before '&&' token
  153 |         explicit stop_callback(const stop_token& st, C&& cb)
      |                                                       ^~
p1663.cpp:154:11: error: expected initializer before 'noexcept'
  154 |           noexcept(is_nothrow_constructible_v<Callback, C>);
      |           ^~~~~~~~
p1663.cpp:156:42: error: expected ',' or '...' before '&&' token
  156 |         explicit stop_callback(stop_token&& st, C&& cb)
      |                                          ^~
p1663.cpp:157:1: error: expected initializer before 'noexcept'
  157 | noexcept(is_nothrow_constructible_v<Callback, C>); ~stop_callback();
      | ^~~~~~~~
p1663.cpp:158:45: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  158 |       stop_callback(const stop_callback&) = delete;
      |                                             ^~~~~~
p1663.cpp:159:34: error: expected ',' or '...' before '&&' token
  159 |       stop_callback(stop_callback&&) = delete;
      |                                  ^~
p1663.cpp:159:40: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  159 |       stop_callback(stop_callback&&) = delete;
      |                                        ^~~~~~
p1663.cpp:159:7: error: invalid constructor; you probably meant 'std::stop_callback<Callback> (const std::stop_callback<Callback>&)'
  159 |       stop_callback(stop_callback&&) = delete;
      |       ^~~~~~~~~~~~~
p1663.cpp:160:56: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  160 |       stop_callback& operator=(const stop_callback&) = delete;
      |                                                        ^~~~~~
p1663.cpp:161:45: error: expected ',' or '...' before '&&' token
  161 |       stop_callback& operator=(stop_callback&&) = delete;
      |                                             ^~
p1663.cpp:161:51: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  161 |       stop_callback& operator=(stop_callback&&) = delete;
      |                                                   ^~~~~~
p1663.cpp:166:65: error: expected constructor, destructor, or type conversion before ';' token
  166 |   stop_callback(stop_token, Callback) -> stop_callback<Callback>;
      |                                                                 ^
p1663.cpp:172:50: error: expected ',' or '...' before '&&' token
  172 |    explicit stop_callback(const stop_token& st, C&& cb)
      |                                                  ^~
p1663.cpp:173:6: error: expected initializer before 'noexcept'
  173 |      noexcept(is_nothrow_constructible_v<Callback, C>);
      |      ^~~~~~~~
p1663.cpp:175:37: error: expected ',' or '...' before '&&' token
  175 |    explicit stop_callback(stop_token&& st, C&& cb)
      |                                     ^~
p1663.cpp:176:1: error: expected initializer before 'noexcept'
  176 | noexcept(is_nothrow_constructible_v<Callback, C>);
      | ^~~~~~~~

$ g++ p1663.cpp -std=2b -o p1663g -I. -Wall
p1663.cpp:49:36: warning: attribute ignored [-Wattributes]
   49 |          [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
      |                                    ^~~~~~~~
p1663.cpp:49:36: note: an attribute that appertains to a friend declaration that is not a definition is ignored
p1663.cpp:54:25: error: expected constructor, destructor, or type conversion before ';' token
   54 |    stop_token() noexcept;
      |                         ^
p1663.cpp:57:43: error: expected constructor, destructor, or type conversion before ';' token
   57 | stop_token(const stop_token& rhs) noexcept;
      |                                           ^
p1663.cpp:60:38: error: expected constructor, destructor, or type conversion before ';' token
   60 | stop_token(stop_token&& rhs) noexcept;
      |                                      ^
p1663.cpp:62:14: error: expected constructor, destructor, or type conversion before ';' token
   62 | ~stop_token();
      |              ^
p1663.cpp:64:13: error: 'std::stop_token& operator=(const std::stop_token&)' must be a non-static member function
   64 | stop_token& operator=(const stop_token& rhs) noexcept;
      |             ^~~~~~~~
p1663.cpp:66:13: error: 'std::stop_token& operator=(std::stop_token&&)' must be a non-static member function
   66 | stop_token& operator=(stop_token&& rhs) noexcept;
      |             ^~~~~~~~
p1663.cpp:70:43: error: non-member function 'bool stop_requested()' cannot have cv-qualifier
   70 | [[nodiscard]] bool stop_requested() const noexcept;
      |                                           ^~~~~~~~
p1663.cpp:71:1: error: expected unqualified-id before '[' token
   71 | [stoptoken.mem]
      | ^
p1663.cpp:81:1: error: 'friend' used outside of class
   81 | friend void swap(stop_token& x, stop_token& y) noexcept;
      | ^~~~~~
      | ------
p1663.cpp:88:15: error: redefinition of 'struct std::nostopstate_t'
   88 |        struct nostopstate_t {
      |               ^~~~~~~~~~~~~
p1663.cpp:28:12: note: previous definition of 'struct std::nostopstate_t'
   28 |     struct nostopstate_t {
      |            ^~~~~~~~~~~~~
p1663.cpp:91:39: error: redefinition of 'constexpr const std::nostopstate_t std::nostopstate'
   91 |        inline constexpr nostopstate_t nostopstate{};
      |                                       ^~~~~~~~~~~
p1663.cpp:31:36: note: 'constexpr const std::nostopstate_t std::nostopstate' previously defined here
   31 |     inline constexpr nostopstate_t nostopstate{};
      |                                    ^~~~~~~~~~~
p1663.cpp:105:7: warning: attribute ignored [-Wattributes]
  105 |       operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
      |       ^~~~~~~~
p1663.cpp:105:7: note: an attribute that appertains to a friend declaration that is not a definition is ignored
p1663.cpp:110:14: error: expected constructor, destructor, or type conversion before ';' token
  110 | stop_source();
      |              ^
p1663.cpp:111:10: error: ISO C++ forbids declaration of 'stop_source' with no type [-fpermissive]
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:111:1: error: 'explicit' outside class declaration
  111 | explicit stop_source(nostopstate_t) noexcept;
      | ^~~~~~~~
p1663.cpp:114:19: error: reference to 'stop_source' is ambiguous
  114 | stop_source(const stop_source& rhs) noexcept;
      |                   ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:114:1: error: reference to 'stop_source' is ambiguous
  114 | stop_source(const stop_source& rhs) noexcept;
      | ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:114:45: error: expected constructor, destructor, or type conversion before ';' token
  114 | stop_source(const stop_source& rhs) noexcept;
      |                                             ^
p1663.cpp:117:12: error: expected constructor, destructor, or type conversion before '(' token
  117 | stop_source(stop_source&& rhs) noexcept;
      |            ^
p1663.cpp:119:15: error: expected constructor, destructor, or type conversion before ';' token
  119 | ~stop_source();
      |               ^
p1663.cpp:121:1: error: reference to 'stop_source' is ambiguous
  121 | stop_source& operator=(const stop_source& rhs) noexcept;
      | ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:123:1: error: reference to 'stop_source' is ambiguous
  123 | stop_source& operator=(stop_source&& rhs) noexcept;
      | ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:125:6: error: variable or field 'swap' declared void
  125 | void swap(stop_source& rhs) noexcept;
      |      ^~~~
p1663.cpp:125:11: error: reference to 'stop_source' is ambiguous
  125 | void swap(stop_source& rhs) noexcept;
      |           ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:125:24: error: 'rhs' was not declared in this scope
  125 | void swap(stop_source& rhs) noexcept;
      |                        ^~~
p1663.cpp:128:44: error: non-member function 'std::stop_token get_token()' cannot have cv-qualifier
  128 | [[nodiscard]] stop_token get_token() const noexcept;
      |                                            ^~~~~~~~
p1663.cpp:130:42: error: non-member function 'bool stop_possible()' cannot have cv-qualifier
  130 | [[nodiscard]] bool stop_possible() const noexcept;
      |                                          ^~~~~~~~
p1663.cpp:132:43: error: non-member function 'bool stop_requested()' cannot have cv-qualifier
  132 | [[nodiscard]] bool stop_requested() const noexcept;
      |                                           ^~~~~~~~
p1663.cpp:139:15: error: 'friend' used outside of class
  139 | [[nodiscard]] friend bool
      |               ^~~~~~
      |               ------
p1663.cpp:140:20: error: reference to 'stop_source' is ambiguous
  140 |   operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
      |                    ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:140:44: error: reference to 'stop_source' is ambiguous
  140 |   operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
      |                                            ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:140:3: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type
  140 |   operator==(const stop_source& lhs, const stop_source& rhs) noexcept;
      |   ^~~~~~~~
p1663.cpp:142:1: error: 'friend' used outside of class
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      | ^~~~~~
      | ------
p1663.cpp:142:13: error: variable or field 'swap' declared void
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      |             ^~~~
p1663.cpp:142:18: error: reference to 'stop_source' is ambiguous
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      |                  ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:142:31: error: 'x' was not declared in this scope
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      |                               ^
p1663.cpp:142:34: error: reference to 'stop_source' is ambiguous
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      |                                  ^~~~~~~~~~~
p1663.cpp:95:9: note: candidates are: 'class std::stop_source'
   95 |   class stop_source {
      |         ^~~~~~~~~~~
p1663.cpp:111:10: note:                 'int stop_source(std::nostopstate_t)'
  111 | explicit stop_source(nostopstate_t) noexcept;
      |          ^~~~~~~~~~~
p1663.cpp:142:47: error: 'y' was not declared in this scope; did you mean 'yn'?
  142 | friend void swap(stop_source& x, stop_source& y) noexcept;
      |                                               ^
      |                                               yn
p1663.cpp:173:42: error: 'Callback' was not declared in this scope
  173 |      noexcept(is_nothrow_constructible_v<Callback, C>);
      |                                          ^~~~~~~~
p1663.cpp:172:13: error: deduction guide for 'std::stop_callback<Callback>' must have trailing return type
  172 |    explicit stop_callback(const stop_token& st, C&& cb)
      |             ^~~~~~~~~~~~~
p1663.cpp:33:32: note: 'template<class Callback> class std::stop_callback' declared here
   33 | template<class Callback> class stop_callback;
      |                                ^~~~~~~~~~~~~
p1663.cpp:176:37: error: 'Callback' was not declared in this scope
  176 | noexcept(is_nothrow_constructible_v<Callback, C>);
      |                                     ^~~~~~~~
p1663.cpp:175:13: error: deduction guide for 'std::stop_callback<Callback>' must have trailing return type
  175 |    explicit stop_callback(stop_token&& st, C&& cb)
      |             ^~~~~~~~~~~~~
p1663.cpp:33:32: note: 'template<class Callback> class std::stop_callback' declared here
   33 | template<class Callback> class stop_callback;
      |                                ^~~~~~~~~~~~~
```

# 検討事項(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 初稿 　20220921
ver. 0.02 33.4を間違えて混ぜていた。削除 20220922