22.8.6.1 General [expected.object.general] C++N4910:2022 (593) p720.cpp

# はじめに(Introduction)

N4910  Working Draft, Standard for Programming Language C++

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

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

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

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

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

https://stackoverflow.com
https://cpprefjp.github.io
http://ja.cppreference.com/

また
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

### 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

## 編纂器(Compiler)
### clang++ --version
> Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
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.

# 22.8.6.1 General [expected.object.general] C++N4910:2022 (593) p720.cpp

## 算譜(source code)

```c++:p720.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 = "22.8.6.1 General [expected.object.general] C++N4910:2022 (593) p720.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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <coroutine>
#include <vector>
#include <complex>
#include <map>
#include <atomic>
#include <unordered_map>
#include <optional>
#include <memory>
#include <variant>
#include <any>
#include <typeinfo>

using namespace std;

// Example 1
namespace std {
template<class T, class E>
class expected {
public:
    using value_type = T;
    using error_type = E;
    using unexpected_type = unexpected<E>;
    template<class U>
    using rebind = expected<U, error_type>;
// 22.8.6.2, constructors
    constexpr expected();
    constexpr explicit(see_below) expected(const expected&);
    constexpr explicit(see_below) expected(expected&&) noexcept(see_below);
    template<class U, class G>
    constexpr explicit(see_below) expected(const expected<U, G>&);
    template<class U, class G>
    constexpr explicit(see_below) expected(expected<U, G>&&);
    template<class U = T>
    constexpr explicit(see_below) expected(U&& v);
    template<class G>
    constexpr expected(const unexpected<G>&);
    template<class G>
    constexpr expected(unexpected<G>&&);
    template<class... Args>
    constexpr explicit expected(in_place_t, Args&&...);
    template<class U, class... Args>
    constexpr explicit expected(in_place_t, initializer_list<U>, Args&&...);
    template<class... Args>
    constexpr explicit expected(unexpect_t, Args&&...);
    template<class U, class... Args>
    constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
// 22.8.6.3, destructor constexpr ~expected();
// 22.8.6.4, assignment
    constexpr expected& operator=(const expected&);
    constexpr expected& operator=(expected&&) noexcept(see_below);
    template<class U = T> constexpr expected& operator=(U&&);
    template<class G>
    constexpr expected& operator=(const unexpected<G>&);
    template<class G>
    constexpr expected& operator=(unexpected<G>&&);
    template<class... Args>
    constexpr T& emplace(Args&&...) noexcept;
    template<class U, class... Args>
    constexpr T& emplace(initializer_list<U>, Args&&...) noexcept;
// 22.8.6.5, swap
    constexpr void swap(expected&) noexcept(see_below);
    friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
// 22.8.6.6, observers
    constexpr const T* operator->() const noexcept;
    constexpr T* operator->() noexcept;
    constexpr const T& operator*() const & noexcept;
    constexpr T& operator*() & noexcept;
    constexpr const T&& operator*() const && noexcept;
    constexpr T&& operator*() && noexcept;
    constexpr explicit operator bool() const noexcept;
    constexpr bool has_value() const noexcept;
    constexpr const T& value() const &;
    constexpr T& value() &;
    constexpr const T&& value() const &&;
    constexpr T&& value() &&;
    constexpr const E& error() const &;
    constexpr E& error() &;
    constexpr const E&& error() const &&;
    constexpr E&& error() &&;
    template<class U> constexpr T value_or(U&&) const &;
    template<class U> constexpr T value_or(U&&) &&;
// 22.8.6.7, equality operators
    template<class T2, class E2> requires (!is_void_v<T2>)
    friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
    template<class T2>
    friend constexpr bool operator==(const expected&, const T2&);
    template<class E2>
    friend constexpr bool operator==(const expected&, const unexpected<E2>&);
private:
    bool has_val ;
    union {
        T val ;
        E unex ;
    };
};
}
// exposition only
// exposition only // exposition only
// Any object of type expected<T, E> either contains a value of type T or a value of type E within its own storage. Implementations are not permitted to use additional storage, such as dynamic memory, to allocate the object of type T or the object of type E. These objects are allocated in a region of the expected<T, E> storage suitably aligned for the types T and E. Members has_val , val , and unex are provided for exposition only. has_val indicates whether the expected<T, E> object contains an object of type T.
//  A program that instantiates the definition of template expected<T, E> for a reference type, a function type, or for possibly cv-qualified types in_place_t, unexpect_t, or a specialization of unexpected for the T
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
```

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

```ubuntu:bash
$ clang++ p720.cpp -std=03 -o p720l -I. -Wall
In file included from p720.cpp:19:
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 \
 ^
p720.cpp:34:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
      using value_type = T;
                         ^
p720.cpp:35:26: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
      using error_type = E;
                         ^
p720.cpp:36:31: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
      using unexpected_type = unexpected<E>;
                              ^
p720.cpp:36:31: error: no template named 'unexpected'; did you mean 'expected'?
p720.cpp:32:11: note: 'expected' declared here
    class expected {
          ^
p720.cpp:38:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
      using rebind = expected<U, error_type>;
                     ^
p720.cpp:40:1: error: unknown type name 'constexpr'
constexpr expected();
^
p720.cpp:40:11: error: constructor cannot have a return type
constexpr expected();
          ^~~~~~~~
p720.cpp:41:1: error: unknown type name 'constexpr'
constexpr explicit(see_below) expected(const expected&);
^
p720.cpp:41:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see_below) expected(const expected&);
                  ^
p720.cpp:41:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(const expected&);
                   ^
p720.cpp:41:31: error: constructor cannot have a return type
constexpr explicit(see_below) expected(const expected&);
                              ^~~~~~~~
p720.cpp:42:1: error: unknown type name 'constexpr'
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
^
p720.cpp:42:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
                  ^
p720.cpp:42:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
                   ^
p720.cpp:42:48: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
                                               ^
p720.cpp:42:31: error: constructor cannot have a return type
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
                              ^~~~~~~~
p720.cpp:42:51: error: expected ';' at end of declaration list
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
                                                  ^
                                                  ;
p720.cpp:44:1: error: unknown type name 'constexpr'
constexpr explicit(see_below) expected(const expected<U, G>&); 
^
p720.cpp:44:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see_below) expected(const expected<U, G>&); 
                  ^
p720.cpp:44:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(const expected<U, G>&); 
                   ^
p720.cpp:44:31: error: constructor cannot have a return type
constexpr explicit(see_below) expected(const expected<U, G>&); 
                              ^~~~~~~~
p720.cpp:46:1: error: unknown type name 'constexpr'
constexpr explicit(see_below) expected(expected<U, G>&&); 
^
p720.cpp:46:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see_below) expected(expected<U, G>&&); 
                  ^
p720.cpp:46:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(expected<U, G>&&); 
                   ^
p720.cpp:46:54: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr explicit(see_below) expected(expected<U, G>&&); 
                                                     ^
p720.cpp:46:31: error: constructor cannot have a return type
constexpr explicit(see_below) expected(expected<U, G>&&); 
                              ^~~~~~~~
p720.cpp:48:1: error: unknown type name 'constexpr'
constexpr explicit(see_below) expected(U&& v);
^
p720.cpp:48:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see_below) expected(U&& v);
                  ^
p720.cpp:48:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(U&& v);
                   ^
p720.cpp:48:41: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr explicit(see_below) expected(U&& v);
                                        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
12 warnings and 20 errors generated.
$ clang++ p720.cpp -std=2b -o p720l -I. -Wall
p720.cpp:36:31: error: expected a type
      using unexpected_type = unexpected<E>;
                              ^
p720.cpp:36:43: error: expected ';' after alias declaration
      using unexpected_type = unexpected<E>;
                                          ^
                                          ;
p720.cpp:41:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(const expected&);
                   ^
p720.cpp:42:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(expected&&) noexcept(see_below); 
                   ^
p720.cpp:44:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(const expected<U, G>&); 
                   ^
p720.cpp:46:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(expected<U, G>&&); 
                   ^
p720.cpp:48:20: error: use of undeclared identifier 'see_below'
constexpr explicit(see_below) expected(U&& v);
                   ^
p720.cpp:50:28: error: parameter name cannot have template arguments
  constexpr expected(const unexpected<G>&);
                           ^
p720.cpp:50:28: error: C++ requires a type specifier for all declarations
  constexpr expected(const unexpected<G>&);
                     ~~~~~ ^
p720.cpp:50:41: error: expected ')'
  constexpr expected(const unexpected<G>&);
                                        ^
p720.cpp:50:21: note: to match this '('
  constexpr expected(const unexpected<G>&);
                    ^
p720.cpp:52:35: error: expected ')'
  constexpr expected(unexpected<G>&&);
                                  ^
p720.cpp:52:21: note: to match this '('
  constexpr expected(unexpected<G>&&);
                    ^
p720.cpp:52:3: error: non-static data member cannot be constexpr; did you intend to make it const?
  constexpr expected(unexpected<G>&&);
  ^~~~~~~~~
  const
p720.cpp:52:22: error: member 'unexpected' declared as a template
  constexpr expected(unexpected<G>&&);
                     ^
p720.cpp:58:31: error: unknown type name 'unexpect_t'
  constexpr explicit expected(unexpect_t, Args&&...);
                              ^
p720.cpp:60:31: error: unknown type name 'unexpect_t'
  constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
                              ^
p720.cpp:66:39: error: parameter name cannot have template arguments
  constexpr expected& operator=(const unexpected<G>&);
                                      ^
p720.cpp:66:39: error: C++ requires a type specifier for all declarations
  constexpr expected& operator=(const unexpected<G>&);
                                ~~~~~ ^
p720.cpp:66:52: error: expected ')'
  constexpr expected& operator=(const unexpected<G>&);
                                                   ^
p720.cpp:66:32: note: to match this '('
  constexpr expected& operator=(const unexpected<G>&);
                               ^
p720.cpp:68:33: error: expected parameter declarator
  constexpr expected& operator=(unexpected<G>&&);
                                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p720.cpp -std=03 -o p720g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from p720.cpp:19:
/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 \
      |  ^~~~~
p720.cpp:40:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   40 | constexpr expected();
      | ^~~~~~~~~
p720.cpp:42:52: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   42 | constexpr explicit(see_below) expected(expected&&) noexcept(see_below);
      |                                                    ^~~~~~~~
p720.cpp:34:13: error: expected nested-name-specifier before 'value_type'
   34 |       using value_type = T;
      |             ^~~~~~~~~~
p720.cpp:35:13: error: expected nested-name-specifier before 'error_type'
   35 |       using error_type = E;
      |             ^~~~~~~~~~
p720.cpp:36:13: error: expected nested-name-specifier before 'unexpected_type'
   36 |       using unexpected_type = unexpected<E>;
      |             ^~~~~~~~~~~~~~~
p720.cpp:38:7: error: expected unqualified-id before 'using'
   38 |       using rebind = expected<U, error_type>;
      |       ^~~~~
p720.cpp:40:1: error: 'constexpr' does not name a type
   40 | constexpr expected();
      | ^~~~~~~~~
p720.cpp:40:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:41:1: error: 'constexpr' does not name a type
   41 | constexpr explicit(see_below) expected(const expected&);
      | ^~~~~~~~~
p720.cpp:41:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:42:1: error: 'constexpr' does not name a type
   42 | constexpr explicit(see_below) expected(expected&&) noexcept(see_below);
      | ^~~~~~~~~
p720.cpp:42:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:44:1: error: 'constexpr' does not name a type
   44 | constexpr explicit(see_below) expected(const expected<U, G>&);
      | ^~~~~~~~~
p720.cpp:44:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:46:1: error: 'constexpr' does not name a type
   46 | constexpr explicit(see_below) expected(expected<U, G>&&);
      | ^~~~~~~~~
p720.cpp:46:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:48:1: error: 'constexpr' does not name a type
   48 | constexpr explicit(see_below) expected(U&& v);
      | ^~~~~~~~~
p720.cpp:48:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:50:3: error: 'constexpr' does not name a type
   50 |   constexpr expected(const unexpected<G>&);
      |   ^~~~~~~~~
p720.cpp:50:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:52:3: error: 'constexpr' does not name a type
   52 |   constexpr expected(unexpected<G>&&);
      |   ^~~~~~~~~
p720.cpp:52:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:53:15: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   53 | template<class... Args>
      |               ^~~
p720.cpp:54:3: error: 'constexpr' does not name a type
   54 |   constexpr explicit expected(in_place_t, Args&&...);
      |   ^~~~~~~~~
p720.cpp:54:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:55:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   55 | template<class U, class... Args>
      |                        ^~~
p720.cpp:56:3: error: 'constexpr' does not name a type
   56 |   constexpr explicit expected(in_place_t, initializer_list<U>, Args&&...);
      |   ^~~~~~~~~
p720.cpp:56:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:57:15: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   57 | template<class... Args>
      |               ^~~
p720.cpp:58:3: error: 'constexpr' does not name a type
   58 |   constexpr explicit expected(unexpect_t, Args&&...);
      |   ^~~~~~~~~
p720.cpp:58:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:59:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   59 | template<class U, class... Args>
      |                        ^~~
p720.cpp:60:3: error: 'constexpr' does not name a type
   60 |   constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
      |   ^~~~~~~~~
p720.cpp:60:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:63:1: error: 'constexpr' does not name a type
   63 | constexpr expected& operator=(const expected&);
      | ^~~~~~~~~
p720.cpp:63:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:64:1: error: 'constexpr' does not name a type
   64 | constexpr expected& operator=(expected&&) noexcept(see_below);
      | ^~~~~~~~~
p720.cpp:64:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:65:23: error: 'constexpr' does not name a type
   65 | template<class U = T> constexpr expected& operator=(U&&); template<class G>
      |                       ^~~~~~~~~
p720.cpp:65:23: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:66:3: error: 'constexpr' does not name a type
   66 |   constexpr expected& operator=(const unexpected<G>&);
      |   ^~~~~~~~~
p720.cpp:66:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:68:3: error: 'constexpr' does not name a type
   68 |   constexpr expected& operator=(unexpected<G>&&);
      |   ^~~~~~~~~
p720.cpp:68:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:69:15: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   69 | template<class... Args>
      |               ^~~
p720.cpp:70:3: error: 'constexpr' does not name a type
   70 |   constexpr T& emplace(Args&&...) noexcept;
      |   ^~~~~~~~~
p720.cpp:70:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:71:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   71 | template<class U, class... Args>
      |                        ^~~
p720.cpp:72:3: error: 'constexpr' does not name a type
   72 |   constexpr T& emplace(initializer_list<U>, Args&&...) noexcept;
      |   ^~~~~~~~~
p720.cpp:72:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:74:1: error: 'constexpr' does not name a type
   74 | constexpr void swap(expected&) noexcept(see_below);
      | ^~~~~~~~~
p720.cpp:74:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:75:8: error: 'constexpr' does not name a type
   75 | friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
      |        ^~~~~~~~~
p720.cpp:75:8: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:77:1: error: 'constexpr' does not name a type
   77 | constexpr const T* operator->() const noexcept;
      | ^~~~~~~~~
p720.cpp:77:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:78:1: error: 'constexpr' does not name a type
   78 | constexpr T* operator->() noexcept;
      | ^~~~~~~~~
p720.cpp:78:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:79:1: error: 'constexpr' does not name a type
   79 | constexpr const T& operator*() const & noexcept;
      | ^~~~~~~~~
p720.cpp:79:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:80:1: error: 'constexpr' does not name a type
   80 | constexpr T& operator*() & noexcept;
      | ^~~~~~~~~
p720.cpp:80:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:81:1: error: 'constexpr' does not name a type
   81 | constexpr const T&& operator*() const && noexcept;
      | ^~~~~~~~~
p720.cpp:81:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:82:1: error: 'constexpr' does not name a type
   82 | constexpr T&& operator*() && noexcept;
      | ^~~~~~~~~
p720.cpp:82:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:83:1: error: 'constexpr' does not name a type
   83 | constexpr explicit operator bool() const noexcept;
      | ^~~~~~~~~
p720.cpp:83:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:84:1: error: 'constexpr' does not name a type
   84 | constexpr bool has_value() const noexcept;
      | ^~~~~~~~~
p720.cpp:84:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:85:1: error: 'constexpr' does not name a type
   85 | constexpr const T& value() const &;
      | ^~~~~~~~~
p720.cpp:85:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:86:1: error: 'constexpr' does not name a type
   86 | constexpr T& value() &;
      | ^~~~~~~~~
p720.cpp:86:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:87:1: error: 'constexpr' does not name a type
   87 | constexpr const T&& value() const &&;
      | ^~~~~~~~~
p720.cpp:87:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:88:1: error: 'constexpr' does not name a type
   88 | constexpr T&& value() &&;
      | ^~~~~~~~~
p720.cpp:88:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:89:1: error: 'constexpr' does not name a type
   89 | constexpr const E& error() const &;
      | ^~~~~~~~~
p720.cpp:89:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:90:1: error: 'constexpr' does not name a type
   90 | constexpr E& error() &;
      | ^~~~~~~~~
p720.cpp:90:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:91:1: error: 'constexpr' does not name a type
   91 | constexpr const E&& error() const &&;
      | ^~~~~~~~~
p720.cpp:91:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:92:1: error: 'constexpr' does not name a type
   92 | constexpr E&& error() &&;
      | ^~~~~~~~~
p720.cpp:92:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:93:19: error: 'constexpr' does not name a type
   93 | template<class U> constexpr T value_or(U&&) const &;
      |                   ^~~~~~~~~
p720.cpp:93:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:94:19: error: 'constexpr' does not name a type
   94 | template<class U> constexpr T value_or(U&&) &&;
      |                   ^~~~~~~~~
p720.cpp:94:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:96:40: error: expected identifier before '!' token
   96 | template<class T2, class E2> requires (!is_void_v<T2>)
      |                                        ^
p720.cpp:96:40: error: expected ',' or '...' before '!' token
p720.cpp:97:3: error: expected constructor, destructor, or type conversion before 'friend'
   97 |   friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
      |   ^~~~~~
p720.cpp:99:10: error: 'constexpr' does not name a type
   99 |   friend constexpr bool operator==(const expected&, const T2&);
      |          ^~~~~~~~~
p720.cpp:99:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p720.cpp:101:10: error: 'constexpr' does not name a type
  101 |   friend constexpr bool operator==(const expected&, const unexpected<E2>&);
      |          ^~~~~~~~~
p720.cpp:101:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'

$ g++ p720.cpp -std=2b -o p720g -I. -Wall
p720.cpp:36:31: error: 'unexpected' does not name a type; did you mean 'expected'?
   36 |       using unexpected_type = unexpected<E>;
      |                               ^~~~~~~~~~
      |                               expected
p720.cpp:41:20: error: 'see_below' was not declared in this scope
   41 | constexpr explicit(see_below) expected(const expected&);
      |                    ^~~~~~~~~
p720.cpp:42:20: error: 'see_below' was not declared in this scope
   42 | constexpr explicit(see_below) expected(expected&&) noexcept(see_below);
      |                    ^~~~~~~~~
p720.cpp:44:20: error: 'see_below' was not declared in this scope
   44 | constexpr explicit(see_below) expected(const expected<U, G>&);
      |                    ^~~~~~~~~
p720.cpp:46:20: error: 'see_below' was not declared in this scope
   46 | constexpr explicit(see_below) expected(expected<U, G>&&);
      |                    ^~~~~~~~~
p720.cpp:48:20: error: 'see_below' was not declared in this scope
   48 | constexpr explicit(see_below) expected(U&& v);
      |                    ^~~~~~~~~
p720.cpp:50:28: error: 'unexpected' does not name a type; did you mean 'expected'?
   50 |   constexpr expected(const unexpected<G>&);
      |                            ^~~~~~~~~~
      |                            expected
p720.cpp:50:38: error: expected ',' or '...' before '<' token
   50 |   constexpr expected(const unexpected<G>&);
      |                                      ^
p720.cpp:52:32: error: expected ')' before '<' token
   52 |   constexpr expected(unexpected<G>&&);
      |                     ~          ^
      |                                )
p720.cpp:58:41: error: expected ')' before ',' token
   58 |   constexpr explicit expected(unexpect_t, Args&&...);
      |                              ~          ^
      |                                         )
p720.cpp:60:41: error: expected ')' before ',' token
   60 |   constexpr explicit expected(unexpect_t, initializer_list<U>, Args&&...);
      |                              ~          ^
      |                                         )
p720.cpp:66:39: error: 'unexpected' does not name a type; did you mean 'expected'?
   66 |   constexpr expected& operator=(const unexpected<G>&);
      |                                       ^~~~~~~~~~
      |                                       expected
p720.cpp:66:49: error: expected ',' or '...' before '<' token
   66 |   constexpr expected& operator=(const unexpected<G>&);
      |                                                 ^
p720.cpp:68:33: error: 'unexpected' has not been declared
   68 |   constexpr expected& operator=(unexpected<G>&&);
      |                                 ^~~~~~~~~~
p720.cpp:68:43: error: expected ',' or '...' before '<' token
   68 |   constexpr expected& operator=(unexpected<G>&&);
      |                                           ^
p720.cpp:68:23: error: 'template<class T, class E> template<class G> constexpr std::expected<T, E>& std::expected<T, E>::operator=(int)' cannot be overloaded with 'template<class T, class E> template<class G> constexpr std::expected<T, E>& std::expected<T, E>::operator=(int)'
   68 |   constexpr expected& operator=(unexpected<G>&&);
      |                       ^~~~~~~~
p720.cpp:66:23: note: previous declaration 'template<class T, class E> template<class G> constexpr std::expected<T, E>& std::expected<T, E>::operator=(int)'
   66 |   constexpr expected& operator=(const unexpected<G>&);
      |                       ^~~~~~~~
p720.cpp:75:82: warning: friend declaration 'constexpr void std::swap(expected<T, E>&, expected<T, E>&)' declares a non-template function [-Wnon-template-friend]
   75 | friend constexpr void swap(expected& x, expected& y) noexcept(noexcept(x.swap(y)));
      |                                                                                  ^
p720.cpp:75:82: note: (if this is not what you intended, make sure the function template has already been declared and add '<>' after the function name here)
p720.cpp:101:59: error: 'unexpected' does not name a type; did you mean 'expected'?
  101 |   friend constexpr bool operator==(const expected&, const unexpected<E2>&);
      |                                                           ^~~~~~~~~~
      |                                                           expected
p720.cpp:101:69: error: expected ',' or '...' before '<' token
  101 |   friend constexpr bool operator==(const expected&, const unexpected<E2>&);
      |                                                                     ^
p720.cpp:42:61: error: 'see_below' was not declared in this scope
   42 | constexpr explicit(see_below) expected(expected&&) noexcept(see_below);
      |                                                             ^~~~~~~~~
p720.cpp:64:52: error: 'see_below' was not declared in this scope
   64 | constexpr expected& operator=(expected&&) noexcept(see_below);
      |                                                    ^~~~~~~~~
p720.cpp:74:41: error: 'see_below' was not declared in this scope
   74 | constexpr void swap(expected&) noexcept(see_below);
      |                                         ^~~~~~~~~
```

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

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

# 参考資料(reference)

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

https://cpprefjp.github.io/

コンパイラの実装状況

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


typedef は C++11 ではオワコン

https://qiita.com/Linda_pp/items/44a67c64c14cba00eef1

C99からC++14を駆け抜けるC++講座

https://qiita.com/yumetodo/items/e49a673afd9a3ecb81a8


@kazuo_reve 私が効果を確認した「小川メソッド」

https://qiita.com/kazuo_reve/items/a3ea1d9171deeccc04da

## 自己参照(self reference)

ockerにclang

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

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

https://qiita.com/drafts/059874ea39c4de64c0f7

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

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

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

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

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

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

コピペコンパイルエラーあるある

https://qiita.com/kaizen_nagoya/items/29c832de9d762aed2761

C++ Error Message Collection(1)does not name a type, 11 articles

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

dockerにclang

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

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

https://qiita.com/drafts/059874ea39c4de64c0f7

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

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

Compare the contents of C++N4910:2022, C++N4741:2018 and C++N4606:2015

https://qiita.com/kaizen_nagoya/items/483246d40f98abff7ded

C++ sample list

https://qiita.com/kaizen_nagoya/items/54ad75b73825b7c04f86

clang++, g++コンパイルエラー方針の違いの例

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

astyle 使ってみた

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

C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

Clang/Clang++(LLVM) gcc/g++(GNU) コンパイラ警告等比較
https://qiita.com/kaizen_nagoya/items/9a82b958cc3aeef0403f

C++2003とC++2017でコンパイルエラーになるならない事例集
https://qiita.com/kaizen_nagoya/items/a13ea3823441c430edff

Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d

cpprefjpのdecltypeをコンパイル試験
https://qiita.com/kaizen_nagoya/items/090909af702f0d5d8a67

MISRA C++ 5-0-16
https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74

C++ Templates Part1 BASICS Chapter 3. Class Templates 3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed

ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1

C言語（C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

'wchar.h' file not found で困った clang++ macOS
https://qiita.com/kaizen_nagoya/items/de15cd46d657517fac11

Open POSIX Test Suiteの使い方を調べはじめました
https://qiita.com/kaizen_nagoya/items/644d5e407f5faf96e6dc

MISRA-C 2012 Referenceに掲載している文献の入手可能性を確認
https://qiita.com/kaizen_nagoya/items/96dc8b125e462d5575bb

どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00

MISRA C まとめ #include <misra_c.h>
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9

「C++完全理解ガイド」の同意できること上位10
https://qiita.com/kaizen_nagoya/items/aa5744e0c4a8618c7671

DoCAP（ドゥーキャップ）って何ですか？

https://qiita.com/kaizen_nagoya/items/47e0e6509ab792c43327

小川メソッド　覚え（書きかけ）

https://qiita.com/kaizen_nagoya/items/3593d72eca551742df68


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

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