33.9 Coordination types [thread.coord] C++N4910:2022 (715) p1735.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.9 Coordination types [thread.coord] C++N4910:2022 (714) p1735.cpp

## 算譜(source code)

```c++:p1735.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.9 Coordination types [thread.coord] C++N4910:2022 (714) p1735.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.9.1 General [thread.coord.general]
// Returns: The maximum value of counter that the implementation supports.
// 33.9.2 Latches [thread.latch]
// 33.9.2.1 General [thread.latch.general]
//  A latch is a thread coordination mechanism that allows any number of threads to block until an expected number of threads arrive at the latch (via the count_down function). The expected count is set when the latch is created. An individual latch is a single-use object; once the expected count has been reached, the latch cannot be reused.
// 33.9.2.2 Header <latch> synopsis [latch.syn]
namespace std {
class latch;
}
// 33.9.2.3 Class latch [thread.latch.class]
namespace std {
class latch {
public:
    static constexpr ptrdiff_t max() noexcept;
    constexpr explicit latch(ptrdiff_t expected);
    ~latch();
    latch(const latch&) = delete;
    latch& operator=(const latch&) = delete;
    void count_down(ptrdiff_t update = 1);
    bool try_wait() const noexcept;
    void wait() const;
    void arrive_and_wait(ptrdiff_t update = 1);
private:
    ptrdiff_t counter; // exposition only
};
}
//  A latch maintains an internal counter that is initialized when the latch is created. Threads can block on the latch object, waiting for counter to be decremented to zero.
//  Concurrent invocations of the member functions of latch, other than its destructor, do not introduce data races.
static constexpr ptrdiff_t max() noexcept;
constexpr explicit latch(ptrdiff_t expected);
// Preconditions: expected >= 0 is true and expected <= max() is true.
// Effects: Initializes counter with expected.
// Throws: Nothing.
void count_down(ptrdiff_t update = 1);
// Preconditions: update >= 0 is true, and update <= counter is true.
// Effects: Atomically decrements counter by update. If counter is equal to zero, unblocks all threads blocked on *this.
// Synchronization: Strongly happens before the returns from all calls that are unblocked. Throws: system_error when an exception is required (33.2.2).
// Error conditions: Any of the error conditions allowed for mutex types (33.6.4.2).
bool try_wait() const noexcept;
Returns:
With very low probability false. Otherwise counter == 0.
// — The expected count is decremented by each call to arrive or arrive_and_drop.
// — When the expected count reaches zero, the phase completion step is run. For the specialization with the default value of the CompletionFunction template parameter, the completion step is run as part of the call to arrive or arrive_and_drop that caused the expected count to reach zero. For other specializations, the completion step is run on one of the threads that arrived at the barrier during the phase.
void wait() const;
// Effects: If counter equals zero, returns immediately. Otherwise, blocks on *this until a call to count_down that decrements counter to zero.
// Throws: system_error when an exception is required (33.2.2).
// Error conditions: Any of the error conditions allowed for mutex types (33.6.4.2).
void arrive_and_wait(ptrdiff_t update = 1);
// Effects: Equivalent to: count_down(update);
wait();
// 33.9.3 Barriers [thread.barrier]
// 33.9.3.1 General [thread.barrier.general]
//  A barrier is a thread coordination mechanism whose lifetime consists of a sequence of barrier phases, where each phase allows at most an expected number of threads to block until the expected number of threads arrive at the barrier.
// [Note 1: A barrier is useful for managing repeated tasks that are handled by multiple threads.
// 33.9.3.2 Header <barrier> synopsis [barrier.syn]
namespace std {
template<class CompletionFunction = see below>
class barrier;
}
// 33.9.3.3 Class template barrier [thread.barrier.class]
namespace std {
template<class CompletionFunction = see below> class barrier {
public:
    using arrival_token = see below;
    static constexpr ptrdiff_t max() noexcept;
    constexpr explicit barrier(ptrdiff_t expected,
                               CompletionFunction f = CompletionFunction());
    ~barrier();
    barrier(const barrier&) = delete;
    barrier& operator=(const barrier&) = delete;
    [[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
    void wait(arrival_token&& arrival) const;
    void arrive_and_wait();
    void arrive_and_drop();
private:
    CompletionFunction completion;
};
}
// exposition only
//  Each barrier phase consists of the following steps:
// — When the completion step finishes, the expected count is reset to what was specified by the expected argument to the constructor, possibly adjusted by calls to arrive_and_drop, and the next phase starts.
//  Each phase defines a phase synchronization point. Threads that arrive at the barrier during the phase can block on the phase synchronization point by calling wait, and will remain blocked until the phase completion step is run.
//  The phase completion step that is executed at the end of each phase has the following effects:
// — Invokes the completion function, equivalent to completion().
// — Unblocks all threads that are blocked on the phase synchronization point.(3.1) (3.2)
//  Concurrent invocations of the member functions of barrier, other than its destructor, do not introduce data races. The member functions arrive and arrive_and_drop execute atomically.
//  CompletionFunction shall meet the Cpp17MoveConstructible (Table 30) and Cpp17Destructible (Table 34) requirements. is_nothrow_invocable_v<CompletionFunction&> shall be true.
//  The default value of the CompletionFunction template parameter is an unspecified type, such that, in addition to satisfying the requirements of CompletionFunction, it meets the Cpp17DefaultConstructible requirements (Table 29) and completion() has no effects.
//  barrier::arrival_token is an unspecified type, such that it meets the Cpp17MoveConstructible (Table 30), Cpp17MoveAssignable (Table 32), and Cpp17Destructible (Table 34) requirements.
static constexpr ptrdiff_t max() noexcept;
// The end of the completion step strongly happens before the returns from all calls that were unblocked by the completion step. For specializations that do not have the default value of the CompletionFunction template parameter, the behavior is undefined if any of the barrier object’s member functions other than wait are called while the completion step is in progress.
// Returns: The maximum expected count that the implementation supports. constexpr explicit barrier(ptrdiff_t expected,
CompletionFunction f = CompletionFunction());
// Preconditions: expected >= 0 is true and expected <= max() is true.
// Effects: Sets both the initial expected count for each barrier phase and the current expected count for the first phase to expected. Initializes completion with std::move(f). Starts the first phase.
// [Note 1: If expected is 0 this object can only be destroyed.
// Throws: Any exception thrown by CompletionFunction’s move constructor.
[[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
// Preconditions: update > 0 is true, and update is less than or equal to the expected count for the current barrier phase.
// Effects: Constructs an object of type arrival_token that is associated with the phase synchronization point for the current phase. Then, decrements the expected count by update.
// Synchronization: The call to arrive strongly happens before the start of the phase completion step for the current phase.
// Returns: The constructed arrival_token object.
// Throws: system_error when an exception is required (33.2.2).
// Error conditions: Any of the error conditions allowed for mutex types (33.6.4.2). [Note 2: This call can cause the completion step for the current phase to start. —end note]
void wait(arrival_token&& arrival) const;
// Preconditions: arrival is associated with the phase synchronization point for the current phase or the immediately preceding phase of the same barrier object.
// Effects: Blocks at the synchronization point associated with std::move(arrival) until the phase completion step of the synchronization point’s phase is run.
// [Note 3 : If arrival is associated with the synchronization point for a previous phase, the call returns immediately.
// Throws: system_error when an exception is required (33.2.2).
// Error conditions: Any of the error conditions allowed for mutex types (33.6.4.2).
void arrive_and_wait();
// Effects: Equivalent to: wait(arrive()).
void arrive_and_drop();
// Preconditions: The expected count for the current barrier phase is greater than zero.
// Effects: Decrements the initial expected count for all subsequent phases by one. Then decrements the expected count for the current phase by one.
// Synchronization: The call to arrive_and_drop strongly happens before the start of the phase completion step for the current phase.
// Throws: system_error when an exception is required (33.2.2).
// Error conditions: Any of the error conditions allowed for mutex types (33.6.4.2).
// [Note 4: This call can cause the completion step for the current phase to start.
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
```

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

```ubuntu:bash
$ clang++ p1735.cpp -std=03 -o p1735l -I. -Wall
In file included from p1735.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 \
 ^
p1735.cpp:27:14: error: unknown type name 'constexpr'
      static constexpr ptrdiff_t max() noexcept;
             ^
p1735.cpp:27:33: error: expected ';' at end of declaration list
      static constexpr ptrdiff_t max() noexcept;
                                ^
                                ;
p1735.cpp:28:7: error: unknown type name 'constexpr'
      constexpr explicit latch(ptrdiff_t expected);
      ^
p1735.cpp:28:32: error: unknown type name 'ptrdiff_t'
      constexpr explicit latch(ptrdiff_t expected);
                               ^
p1735.cpp:28:26: error: constructor cannot have a return type
      constexpr explicit latch(ptrdiff_t expected);
                         ^~~~~
p1735.cpp:30:23: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
latch(const latch&) = delete;
                      ^
p1735.cpp:31:40: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
      latch& operator=(const latch&) = delete;
                                       ^
p1735.cpp:32:23: error: unknown type name 'ptrdiff_t'
      void count_down(ptrdiff_t update = 1);
                      ^
p1735.cpp:33:28: error: expected ';' at end of declaration list
      bool try_wait() const noexcept;
                           ^
                           ;
p1735.cpp:35:28: error: unknown type name 'ptrdiff_t'
      void arrive_and_wait(ptrdiff_t update = 1);
                           ^
p1735.cpp:37:1: error: unknown type name 'ptrdiff_t'
ptrdiff_t counter; // exposition only
^
p1735.cpp:41:11: error: unknown type name 'constexpr'
   static constexpr ptrdiff_t max() noexcept;
          ^
p1735.cpp:41:30: error: expected ';' after top level declarator
   static constexpr ptrdiff_t max() noexcept;
                             ^
                             ;
p1735.cpp:42:1: error: unknown type name 'constexpr'
constexpr explicit latch(ptrdiff_t expected);
^
p1735.cpp:51:23: error: expected function body after function declarator
bool try_wait() const noexcept;
                      ^
p1735.cpp:52:1: error: unknown type name 'Returns'
Returns: With very low probability false. Otherwise counter == 0.
^
p1735.cpp:52:8: error: expected unqualified-id
Returns: With very low probability false. Otherwise counter == 0.
       ^
p1735.cpp:61:1: error: C++ requires a type specifier for all declarations
wait();
^
p1735.cpp:68:37: error: unknown type name 'see'
template<class CompletionFunction = see below>
                                    ^
p1735.cpp:68:41: error: expected ',' or '>' in template-parameter-list
template<class CompletionFunction = see below>
                                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
$ clang++ p1735.cpp -std=2b -o p1735l -I. -Wall
p1735.cpp:42:36: error: expected ')'
constexpr explicit latch(ptrdiff_t expected);
                                   ^
p1735.cpp:42:25: note: to match this '('
constexpr explicit latch(ptrdiff_t expected);
                        ^
p1735.cpp:42:11: error: 'explicit' can only appear on non-static member functions
constexpr explicit latch(ptrdiff_t expected);
          ^
p1735.cpp:42:26: error: constexpr variable cannot have non-literal type 'std::latch (const'
constexpr explicit latch(ptrdiff_t expected);
                         ^
p1735.cpp:29:1: note: 'latch' is not literal because its destructor is not constexpr
~latch();
^
p1735.cpp:51:17: error: non-member function cannot have 'const' qualifier
bool try_wait() const noexcept;
                ^~~~~~
p1735.cpp:52:1: error: unknown type name 'Returns'
Returns: With very low probability false. Otherwise counter == 0.
^
p1735.cpp:52:8: error: expected unqualified-id
Returns: With very low probability false. Otherwise counter == 0.
       ^
p1735.cpp:61:1: error: C++ requires a type specifier for all declarations
wait();
^
p1735.cpp:68:37: error: unknown type name 'see'
template<class CompletionFunction = see below>
                                    ^
p1735.cpp:68:41: error: expected ',' or '>' in template-parameter-list
template<class CompletionFunction = see below>
                                        ^
p1735.cpp:73:37: error: unknown type name 'see'
template<class CompletionFunction = see below> class barrier {
                                    ^
p1735.cpp:73:41: error: expected ',' or '>' in template-parameter-list
template<class CompletionFunction = see below> class barrier {
                                        ^
p1735.cpp:75:23: error: unknown type name 'see'
using arrival_token = see below;
                      ^
p1735.cpp:75:27: error: type-id cannot have a name
using arrival_token = see below;
                          ^~~~~
p1735.cpp:81:15: error: unknown type name 'arrival_token'
[[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
              ^
p1735.cpp:82:11: error: unknown type name 'arrival_token'
void wait(arrival_token&& arrival) const;
          ^
p1735.cpp:102:23: error: unknown type name 'CompletionFunction'
                      CompletionFunction f = CompletionFunction());
                      ^
p1735.cpp:102:46: error: use of undeclared identifier 'CompletionFunction'
                      CompletionFunction f = CompletionFunction());
                                             ^
p1735.cpp:102:66: error: extraneous ')' before ';'
                      CompletionFunction f = CompletionFunction());
                                                                 ^
p1735.cpp:107:15: error: unknown type name 'arrival_token'
[[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
              ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1735.cpp -std=03 -o p1735g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1735.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 \
      |  ^~~~~
p1735.cpp:27:14: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   27 |       static constexpr ptrdiff_t max() noexcept;
      |              ^~~~~~~~~
p1735.cpp:27:40: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   27 |       static constexpr ptrdiff_t max() noexcept;
      |                                        ^~~~~~~~
p1735.cpp:27:14: error: 'constexpr' does not name a type
   27 |       static constexpr ptrdiff_t max() noexcept;
      |              ^~~~~~~~~
p1735.cpp:27:14: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1735.cpp:28:7: error: 'constexpr' does not name a type
   28 |       constexpr explicit latch(ptrdiff_t expected);
      |       ^~~~~~~~~
p1735.cpp:28:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1735.cpp:30:23: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   30 | latch(const latch&) = delete;
      |                       ^~~~~~
p1735.cpp:31:40: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   31 |       latch& operator=(const latch&) = delete;
      |                                        ^~~~~~
p1735.cpp:33:23: error: expected ';' at end of member declaration
   33 |       bool try_wait() const noexcept;
      |                       ^~~~~
      |                            ;
p1735.cpp:33:29: error: 'noexcept' does not name a type
   33 |       bool try_wait() const noexcept;
      |                             ^~~~~~~~
p1735.cpp:33:29: note: C++11 'noexcept' only available with '-std=c++11' or '-std=gnu++11'
p1735.cpp:41:11: error: 'constexpr' does not name a type
   41 |    static constexpr ptrdiff_t max() noexcept;
      |           ^~~~~~~~~
p1735.cpp:41:11: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1735.cpp:42:1: error: 'constexpr' does not name a type
   42 | constexpr explicit latch(ptrdiff_t expected);
      | ^~~~~~~~~
p1735.cpp:42:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1735.cpp:51:23: error: expected initializer before 'noexcept'
   51 | bool try_wait() const noexcept;
      |                       ^~~~~~~~
p1735.cpp:52:8: error: found ':' in nested-name-specifier, expected '::'
   52 | Returns: With very low probability false. Otherwise counter == 0.
      |        ^
      |        ::
p1735.cpp:52:1: error: 'Returns' does not name a type
   52 | Returns: With very low probability false. Otherwise counter == 0.
      | ^~~~~~~
p1735.cpp:61:7: error: expected constructor, destructor, or type conversion before ';' token
   61 | wait();
      |       ^
p1735.cpp:68:37: error: 'see' does not name a type
   68 | template<class CompletionFunction = see below>
      |                                     ^~~
p1735.cpp:68:41: error: expected '>' before 'below'
   68 | template<class CompletionFunction = see below>
      |                                         ^~~~~
p1735.cpp:73:37: error: 'see' does not name a type
   73 | template<class CompletionFunction = see below> class barrier {
      |                                     ^~~
p1735.cpp:73:41: error: expected '>' before 'below'
   73 | template<class CompletionFunction = see below> class barrier {
      |                                         ^~~~~
p1735.cpp:73:10: error: redefinition of default argument for 'class CompletionFunction'
   73 | template<class CompletionFunction = see below> class barrier {
      |          ^~~~~
p1735.cpp:68:10: note: original definition appeared here
   68 | template<class CompletionFunction = see below>
      |          ^~~~~
p1735.cpp:99:13: error: 'constexpr' does not name a type
   99 |      static constexpr ptrdiff_t max() noexcept;
      |             ^~~~~~~~~
p1735.cpp:99:13: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1735.cpp:102:23: error: 'CompletionFunction' does not name a type
  102 |                       CompletionFunction f = CompletionFunction());
      |                       ^~~~~~~~~~~~~~~~~~
p1735.cpp:107:1: error: expected unqualified-id before '[' token
  107 | [[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
      | ^
p1735.cpp:114:6: error: variable or field 'wait' declared void
  114 | void wait(arrival_token&& arrival) const;
      |      ^~~~
p1735.cpp:114:11: error: 'arrival_token' was not declared in this scope
  114 | void wait(arrival_token&& arrival) const;
      |           ^~~~~~~~~~~~~
p1735.cpp:114:27: error: 'arrival' was not declared in this scope
  114 | void wait(arrival_token&& arrival) const;
      |                           ^~~~~~~

$ g++ p1735.cpp -std=2b -o p1735g -I. -Wall
p1735.cpp:42:20: error: ISO C++ forbids declaration of 'latch' with no type [-fpermissive]
   42 | constexpr explicit latch(ptrdiff_t expected);
      |                    ^~~~~
p1735.cpp:42:11: error: 'explicit' outside class declaration
   42 | constexpr explicit latch(ptrdiff_t expected);
      |           ^~~~~~~~
p1735.cpp:51:23: error: non-member function 'bool try_wait()' cannot have cv-qualifier
   51 | bool try_wait() const noexcept;
      |                       ^~~~~~~~
p1735.cpp:52:8: error: found ':' in nested-name-specifier, expected '::'
   52 | Returns: With very low probability false. Otherwise counter == 0.
      |        ^
      |        ::
p1735.cpp:52:1: error: 'Returns' does not name a type
   52 | Returns: With very low probability false. Otherwise counter == 0.
      | ^~~~~~~
p1735.cpp:61:7: error: expected constructor, destructor, or type conversion before ';' token
   61 | wait();
      |       ^
p1735.cpp:68:37: error: 'see' does not name a type
   68 | template<class CompletionFunction = see below>
      |                                     ^~~
p1735.cpp:68:41: error: expected '>' before 'below'
   68 | template<class CompletionFunction = see below>
      |                                         ^~~~~
p1735.cpp:73:37: error: 'see' does not name a type
   73 | template<class CompletionFunction = see below> class barrier {
      |                                     ^~~
p1735.cpp:73:41: error: expected '>' before 'below'
   73 | template<class CompletionFunction = see below> class barrier {
      |                                         ^~~~~
p1735.cpp:73:10: error: redefinition of default argument for 'class CompletionFunction'
   73 | template<class CompletionFunction = see below> class barrier {
      |          ^~~~~
p1735.cpp:68:10: note: original definition appeared here
   68 | template<class CompletionFunction = see below>
      |          ^~~~~
p1735.cpp:102:23: error: 'CompletionFunction' does not name a type
  102 |                       CompletionFunction f = CompletionFunction());
      |                       ^~~~~~~~~~~~~~~~~~
p1735.cpp:107:15: error: 'arrival_token' does not name a type
  107 | [[nodiscard]] arrival_token arrive(ptrdiff_t update = 1);
      |               ^~~~~~~~~~~~~
p1735.cpp:114:6: error: variable or field 'wait' declared void
  114 | void wait(arrival_token&& arrival) const;
      |      ^~~~
p1735.cpp:114:11: error: 'arrival_token' was not declared in this scope
  114 | void wait(arrival_token&& arrival) const;
      |           ^~~~~~~~~~~~~
p1735.cpp:114:27: error: 'arrival' was not declared in this scope
  114 | void wait(arrival_token&& arrival) const;
      |                           ^~~~~~~
p1735.cpp:99:33: warning: 'constexpr ptrdiff_t max() noexcept' declared 'static' but never defined [-Wunused-function]
   99 |      static constexpr ptrdiff_t max() 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