29.12 Formatting [time.format] C++N4910:2022 (679) p1437.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

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

# 29.12 Formatting [time.format] C++N4910:2022 (679) p1437.cpp

## 算譜(source code)

```c++:p1437.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 = "29.12 Formatting [time.format] C++N4910:2022 (679) p1437.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;

namespace std::chrono {
// 29.12 Formatting [time.format]
// Each formatter (22.14.6) specialization in the chrono library (29.2) meets the Formatter requirements (22.14.6.1). The parse member functions of these formatters interpret the format specification as a chrono-format-spec according to the following syntax: chrono-format-spec : fill-and-alignopt widthopt precisionopt Lopt chrono-specsopt chrono-specs : conversion-spec chrono-specs conversion-spec chrono-specs literal-char literal-char : any character other than {, }, or % conversion-spec : % modifieropt type modifier: one of EO
// The productions fill-and-align, width, and precision are described in 22.14.2. Giving a precision specification in the chrono-format-spec is valid only for std::chrono::duration types where the representation type Rep is a floating-point type. For all other Rep types, an exception of type format_error is thrown if the chrono-format-spec contains a precision specification. All ordinary multibyte characters represented by literal-char are copied unchanged to the output.
//  A formatting locale is an instance of locale used by a formatting function, defined as
// — the "C" locale if the L option is not present in chrono-format-spec, otherwise — the locale passed to the formatting function if any, otherwise
// — the global locale.
// type: one of aAbBcCdDeFgGhHIjmMn pqQrRStTuUVwWxXyYzZ%
//  Each conversion specifier conversion-spec is replaced by appropriate characters as described in Table 97; the formats specified in ISO 8601:2004 shall be used where so described. Some of the conversion specifiers depend on the formatting locale. If the formatted object does not contain the information the conversion specifier refers to, an exception of type format_error is thrown.
//  The result of formatting a std::chrono::duration instance holding a negative value, or an hh_mm_ss object h for which h.is_negative() is true, is equivalent to the output of the corresponding positive value, with a STATICALLY-WIDEN <charT>("-") character sequence placed before the replacement of the initial conversion specifier.
// [Example 1:
void f() {
    cout << format("{:%T}", -10'000s); // prints: -02:46:40
    cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40
    cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);// prints: minutes -46, hours 02, seconds 40
}
//  Unless explicitly requested, the result of formatting a chrono type does not contain time zone abbreviation and time zone offset information. If the information is available, the conversion specifiers %Z and %z will format this information (respectively).
// [Note 1: If the information is not available and a %Z or %z conversion specifier appears in the chrono-format-spec, an exception of type format_error is thrown, as described above. —end note]
//  If the type being formatted does not contain the information that the format flag needs, an exception of type format_error is thrown.
// [Example 2: A duration does not contain enough information to format as a weekday.
// However, if a flag refers to a “time of day” (e.g. %H, %I, %p, etc.),  then a specialization of duration is interpreted as the time of day elapsed since midnight.
//  If the chrono-specs is omitted, the chrono object is formatted as if by streaming it to std::ostringstream os with the formatting locale imbued and copying os.str() through the output iterator of the context with additional padding and adjustments as specified by the format specifiers.
// [Example 3:
string s = format("{:=>8}", 42ms); // value of s is "====42ms"
template<class Duration, class charT>
struct formatter<chrono::sys_time<Duration>, charT>;
// Remarks: If %Z is used, it is replaced with STATICALLY-WIDEN <charT>("UTC"). If %z (or a modified variant of %z) is used, an offset of 0min is formatted.
template<class Duration, class charT>
struct formatter<chrono::utc_time<Duration>, charT>;
// Remarks: If %Z is used, it is replaced with STATICALLY-WIDEN <charT>("UTC"). If %z (or a modified variant of %z) is used, an offset of 0min is formatted. If the argument represents a time during a positive leap second insertion, and if a seconds field is formatted, the integral portion of that format is STATICALLY-WIDEN <charT>("60").
template<class Duration, class charT>
struct formatter<chrono::tai_time<Duration>, charT>;
// Remarks: If %Z is used, it is replaced with STATICALLY-WIDEN <charT>("TAI"). If %z (or a modified variant of %z) is used, an offset of 0min is formatted. The date and time formatted are equivalent to those formatted by a sys_time initialized with sys_time<Duration>{tp.time_since_epoch()} -  (sys_days{1970y/January/1} - sys_days{1958y/January/1})
template<class Duration, class charT>
struct formatter<chrono::gps_time<Duration>, charT>;
// Remarks: If %Z is used, it is replaced with STATICALLY-WIDEN <charT>("GPS"). If %z (or a modified variant of %z) is used, an offset of 0min is formatted. The date and time formatted are equivalent to those formatted by a sys_time initialized with sys_time<Duration>{tp.time_since_epoch()} +  (sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1})
template<class Duration, class charT>
struct formatter<chrono::file_time<Duration>, charT>;
// Remarks: If %Z is used, it is replaced with STATICALLY-WIDEN <charT>("UTC"). If %z (or a modified variant of %z) is used, an offset of 0min is formatted. The date and time formatted are equivalent to those formatted by a sys_time initialized with clock_cast<system_clock>(t), or by a utc_time initialized with clock_cast<utc_clock>(t), where t is the first argument to format.
template<class Duration> local-time-format-t <Duration>
local_time_format(local_time<Duration> time, const string* abbrev = nullptr,
                  const seconds* offset_sec = nullptr);
// Returns: {time, abbrev, offset_sec}.
template<class Duration, class charT>
struct formatter<chrono::local_time<Duration>, charT>;
// Remarks: If %Z, %z, or a modified version of %z is used, an exception of type format_error is thrown.
template<class Duration> struct local-time-format-t {
    local_time<Duration> time;
    const string* abbrev;
    const seconds* offset_sec;
};
// exposition only // exposition only // exposition only // exposition only
template<class Duration, class charT>
struct formatter<chrono::local-time-format-t<Duration>, charT>;
// Let f be a local-time-format-t <Duration> object passed to formatter::format.
// Remarks: If %Z is used, it is replaced with *f.abbrev if f.abbrev is not a null pointer value. If %Z is used and f.abbrev is a null pointer value, an exception of type format_error is thrown. If %z (or a modified variant of %z) is used, it is formatted with the value of *f.offset_sec if f.offset_sec is not a null pointer value. If %z (or a modified variant of %z) is used and f.offset_sec is a null pointer value, then an exception of type format_error is thrown.
template<class Duration, class TimeZonePtr, class charT>
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
    : formatter<chrono::local-time-format-t<Duration>, charT> {
    template<class FormatContext>
    typename FormatContext::iterator
    format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
};
template<class FormatContext>
typename FormatContext::iterator
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
// Effects: Equivalent to:
sys_info info = tp.get_info();
return formatter<chrono::local-time-format-t<Duration>, charT>::
       format({tp.get_local_time(), &info.abbrev, &info.offset}, ctx);
int main() {
    f();
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}
}
```

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

```ubuntu:bash
$ clang++ p1437.cpp -std=03 -o p1437l -I. -Wall
In file included from p1437.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 \
 ^
p1437.cpp:26:28: warning: missing terminating ' character [-Winvalid-pp-token]
cout << format("{:%T}", -10'000s); // prints: -02:46:40 
                           ^
p1437.cpp:27:34: warning: missing terminating ' character [-Winvalid-pp-token]
cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40 
                                 ^
p1437.cpp:28:58: warning: missing terminating ' character [-Winvalid-pp-token]
cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);// prints: minutes -46, hours 02, seconds 40
                                                         ^
p1437.cpp:14:14: warning: nested namespace definition is a C++17 extension; define each namespace separately [-Wc++17-extensions]
namespace std::chrono {
             ^~~~~~~~
              { namespace chrono
p1437.cpp:26:28: error: expected ')'
cout << format("{:%T}", -10'000s); // prints: -02:46:40 
                           ^
p1437.cpp:26:15: note: to match this '('
cout << format("{:%T}", -10'000s); // prints: -02:46:40 
              ^
p1437.cpp:37:31: error: invalid suffix 'ms' on integer constant
string s = format("{:=>8}", 42ms); // value of s is "====42ms"
                              ^
p1437.cpp:39:26: error: no member named 'sys_time' in namespace 'std::chrono'
struct formatter<chrono::sys_time<Duration>, charT>;
                 ~~~~~~~~^
p1437.cpp:39:35: error: 'Duration' does not refer to a value
struct formatter<chrono::sys_time<Duration>, charT>;
                                  ^
p1437.cpp:38:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:39:8: error: explicit specialization of undeclared template struct 'formatter'
struct formatter<chrono::sys_time<Duration>, charT>;
       ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:39:44: error: expected unqualified-id
struct formatter<chrono::sys_time<Duration>, charT>;
                                           ^
p1437.cpp:42:28: error: no member named 'utc_time' in namespace 'std::chrono'
  struct formatter<chrono::utc_time<Duration>, charT>;
                   ~~~~~~~~^
p1437.cpp:42:37: error: 'Duration' does not refer to a value
  struct formatter<chrono::utc_time<Duration>, charT>;
                                    ^
p1437.cpp:41:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:42:10: error: explicit specialization of non-template struct 'formatter'
  struct formatter<chrono::utc_time<Duration>, charT>;
         ^
p1437.cpp:42:46: error: expected unqualified-id
  struct formatter<chrono::utc_time<Duration>, charT>;
                                             ^
p1437.cpp:45:28: error: no member named 'tai_time' in namespace 'std::chrono'
  struct formatter<chrono::tai_time<Duration>, charT>;
                   ~~~~~~~~^
p1437.cpp:45:37: error: 'Duration' does not refer to a value
  struct formatter<chrono::tai_time<Duration>, charT>;
                                    ^
p1437.cpp:44:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:45:10: error: explicit specialization of non-template struct 'formatter'
  struct formatter<chrono::tai_time<Duration>, charT>;
         ^
p1437.cpp:45:46: error: expected unqualified-id
  struct formatter<chrono::tai_time<Duration>, charT>;
                                             ^
p1437.cpp:48:28: error: no member named 'gps_time' in namespace 'std::chrono'
  struct formatter<chrono::gps_time<Duration>, charT>;
                   ~~~~~~~~^
p1437.cpp:48:37: error: 'Duration' does not refer to a value
  struct formatter<chrono::gps_time<Duration>, charT>;
                                    ^
p1437.cpp:47:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:48:10: error: explicit specialization of non-template struct 'formatter'
  struct formatter<chrono::gps_time<Duration>, charT>;
         ^
p1437.cpp:48:46: error: expected unqualified-id
  struct formatter<chrono::gps_time<Duration>, charT>;
                                             ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 warnings and 20 errors generated.
$ clang++ p1437.cpp -std=2b -o p1437l -I. -Wall
p1437.cpp:26:32: error: no matching literal operator for call to 'operator""s' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template
cout << format("{:%T}", -10'000s); // prints: -02:46:40 
                               ^
p1437.cpp:27:38: error: no matching literal operator for call to 'operator""s' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template
cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40 
                                     ^
p1437.cpp:28:62: error: no matching literal operator for call to 'operator""s' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template
cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);// prints: minutes -46, hours 02, seconds 40
                                                             ^
p1437.cpp:37:31: error: no matching literal operator for call to 'operator""ms' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template
string s = format("{:=>8}", 42ms); // value of s is "====42ms"
                              ^
p1437.cpp:39:26: error: no member named 'sys_time' in namespace 'std::chrono'
struct formatter<chrono::sys_time<Duration>, charT>;
                 ~~~~~~~~^
p1437.cpp:39:35: error: 'Duration' does not refer to a value
struct formatter<chrono::sys_time<Duration>, charT>;
                                  ^
p1437.cpp:38:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:39:8: error: explicit specialization of undeclared template struct 'formatter'
struct formatter<chrono::sys_time<Duration>, charT>;
       ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:39:44: error: expected unqualified-id
struct formatter<chrono::sys_time<Duration>, charT>;
                                           ^
p1437.cpp:42:28: error: no member named 'utc_time' in namespace 'std::chrono'
  struct formatter<chrono::utc_time<Duration>, charT>;
                   ~~~~~~~~^
p1437.cpp:42:37: error: 'Duration' does not refer to a value
  struct formatter<chrono::utc_time<Duration>, charT>;
                                    ^
p1437.cpp:41:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:42:10: error: explicit specialization of non-template struct 'formatter'
  struct formatter<chrono::utc_time<Duration>, charT>;
         ^
p1437.cpp:42:46: error: expected unqualified-id
  struct formatter<chrono::utc_time<Duration>, charT>;
                                             ^
p1437.cpp:45:28: error: no member named 'tai_time' in namespace 'std::chrono'
  struct formatter<chrono::tai_time<Duration>, charT>;
                   ~~~~~~~~^
p1437.cpp:45:37: error: 'Duration' does not refer to a value
  struct formatter<chrono::tai_time<Duration>, charT>;
                                    ^
p1437.cpp:44:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:45:10: error: explicit specialization of non-template struct 'formatter'
  struct formatter<chrono::tai_time<Duration>, charT>;
         ^
p1437.cpp:45:46: error: expected unqualified-id
  struct formatter<chrono::tai_time<Duration>, charT>;
                                             ^
p1437.cpp:48:28: error: no member named 'gps_time' in namespace 'std::chrono'
  struct formatter<chrono::gps_time<Duration>, charT>;
                   ~~~~~~~~^
p1437.cpp:48:37: error: 'Duration' does not refer to a value
  struct formatter<chrono::gps_time<Duration>, charT>;
                                    ^
p1437.cpp:47:16: note: declared here
template<class Duration, class charT>
               ^
p1437.cpp:48:10: error: explicit specialization of non-template struct 'formatter'
  struct formatter<chrono::gps_time<Duration>, charT>;
         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1437.cpp -std=03 -o p1437g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1437.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 \
      |  ^~~~~
p1437.cpp:26:28: warning: missing terminating ' character
   26 | cout << format("{:%T}", -10'000s); // prints: -02:46:40
      |                            ^
p1437.cpp:26:28: error: missing terminating ' character
   26 | cout << format("{:%T}", -10'000s); // prints: -02:46:40
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
p1437.cpp:27:34: warning: missing terminating ' character
   27 | cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40
      |                                  ^
p1437.cpp:27:34: error: missing terminating ' character
   27 | cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
p1437.cpp:28:58: warning: missing terminating ' character
   28 | cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);// prints: minutes -46, hours 02, seconds 40
      |                                                          ^
p1437.cpp:28:58: error: missing terminating ' character
   28 | cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);// prints: minutes -46, hours 02, seconds 40
      |                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1437.cpp:37:29: error: invalid suffix "ms" on integer constant
   37 | string s = format("{:=>8}", 42ms); // value of s is "====42ms"
      |                             ^~~~
p1437.cpp:54:69: warning: identifier 'nullptr' is a keyword in C++11 [-Wc++11-compat]
   54 | local_time_format(local_time<Duration> time, const string* abbrev = nullptr,
      |                                                                     ^~~~~~~
p1437.cpp: In function 'void std::chrono::f()':
p1437.cpp:26:28: error: expected ')' before 'cout'
   26 | cout << format("{:%T}", -10'000s); // prints: -02:46:40
      |               ~            ^
      |                            )
   27 | cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40
      | ~~~~                        
p1437.cpp: At global scope:
p1437.cpp:37:12: error: 'format' was not declared in this scope
   37 | string s = format("{:=>8}", 42ms); // value of s is "====42ms"
      |            ^~~~~~
p1437.cpp:39:8: error: 'formatter' is not a class template
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |        ^~~~~~~~~
p1437.cpp:39:26: error: 'sys_time' is not a member of 'std::chrono'
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |                          ^~~~~~~~
p1437.cpp:39:26: error: 'sys_time' is not a member of 'std::chrono'
p1437.cpp:39:17: error: expected ';' before ',' token
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |                 ^                          ~
      |                 ;
p1437.cpp:42:10: error: 'formatter' is not a class template
   42 |   struct formatter<chrono::utc_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:42:28: error: 'utc_time' is not a member of 'std::chrono'
   42 |   struct formatter<chrono::utc_time<Duration>, charT>;
      |                            ^~~~~~~~
p1437.cpp:42:28: error: 'utc_time' is not a member of 'std::chrono'
p1437.cpp:42:19: error: expected ';' before ',' token
   42 |   struct formatter<chrono::utc_time<Duration>, charT>;
      |                   ^                          ~
      |                   ;
p1437.cpp:45:10: error: 'formatter' is not a class template
   45 |   struct formatter<chrono::tai_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:45:28: error: 'tai_time' is not a member of 'std::chrono'
   45 |   struct formatter<chrono::tai_time<Duration>, charT>;
      |                            ^~~~~~~~
p1437.cpp:45:28: error: 'tai_time' is not a member of 'std::chrono'
p1437.cpp:45:19: error: expected ';' before ',' token
   45 |   struct formatter<chrono::tai_time<Duration>, charT>;
      |                   ^                          ~
      |                   ;
p1437.cpp:48:10: error: 'formatter' is not a class template
   48 |   struct formatter<chrono::gps_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:48:28: error: 'gps_time' is not a member of 'std::chrono'
   48 |   struct formatter<chrono::gps_time<Duration>, charT>;
      |                            ^~~~~~~~
p1437.cpp:48:28: error: 'gps_time' is not a member of 'std::chrono'
p1437.cpp:48:19: error: expected ';' before ',' token
   48 |   struct formatter<chrono::gps_time<Duration>, charT>;
      |                   ^                          ~
      |                   ;
p1437.cpp:51:10: error: 'formatter' is not a class template
   51 |   struct formatter<chrono::file_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:51:28: error: 'file_time' is not a member of 'std::chrono'
   51 |   struct formatter<chrono::file_time<Duration>, charT>;
      |                            ^~~~~~~~~
p1437.cpp:51:28: error: 'file_time' is not a member of 'std::chrono'
p1437.cpp:51:19: error: expected ';' before ',' token
   51 |   struct formatter<chrono::file_time<Duration>, charT>;
      |                   ^                           ~
      |                   ;
p1437.cpp:53:26: error: 'local' does not name a type; did you mean 'locale'?
   53 | template<class Duration> local-time-format-t <Duration>
      |                          ^~~~~
      |                          locale
p1437.cpp:58:10: error: 'formatter' is not a class template
   58 |   struct formatter<chrono::local_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:58:28: error: 'local_time' is not a member of 'std::chrono'
   58 |   struct formatter<chrono::local_time<Duration>, charT>;
      |                            ^~~~~~~~~~
p1437.cpp:58:28: error: 'local_time' is not a member of 'std::chrono'
p1437.cpp:58:19: error: expected ';' before ',' token
   58 |   struct formatter<chrono::local_time<Duration>, charT>;
      |                   ^                            ~
      |                   ;
p1437.cpp:60:38: error: expected unqualified-id before '-' token
   60 | template<class Duration> struct local-time-format-t {
      |                                      ^
p1437.cpp:67:8: error: 'formatter' is not a class template
   67 | struct formatter<chrono::local-time-format-t<Duration>, charT>;
      |        ^~~~~~~~~
p1437.cpp:67:8: error: 'std::chrono::formatter' is not a template
p1437.cpp:39:8: note: previous declaration here
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |        ^~~~~~~~~
p1437.cpp:71:8: error: 'formatter' is not a class template
   71 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
      |        ^~~~~~~~~
p1437.cpp:71:26: error: 'zoned_time' is not a member of 'std::chrono'
   71 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
      |                          ^~~~~~~~~~
p1437.cpp:71:26: error: 'zoned_time' is not a member of 'std::chrono'
p1437.cpp:71:17: error: expected ';' before ',' token
   71 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
      |                 ^                                         ~
      |                 ;
p1437.cpp:79:26: error: 'zoned_time' in namespace 'std::chrono' does not name a template type
   79 |     format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
      |                          ^~~~~~~~~~
p1437.cpp:79:36: error: expected ',' or '...' before '<' token
   79 |     format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
      |                                    ^
p1437.cpp:81:1: error: 'sys_info' does not name a type; did you mean 'type_info'?
   81 | sys_info info = tp.get_info();
      | ^~~~~~~~
      | type_info
p1437.cpp:82:1: error: expected unqualified-id before 'return'
   82 | return formatter<chrono::local-time-format-t<Duration>, charT>::
      | ^~~~~~
p1437.cpp:83:73: error: expected unqualified-id before ',' token
   83 |                 format({tp.get_local_time(), &info.abbrev, &info.offset}, ctx);
      |                                                                         ^
p1437.cpp:83:78: error: expected constructor, destructor, or type conversion before ')' token
   83 |                 format({tp.get_local_time(), &info.abbrev, &info.offset}, ctx);
      |                                                                              ^

$ g++ p1437.cpp -std=2b -o p1437g -I. -Wall
p1437.cpp: In function 'void std::chrono::f()':
p1437.cpp:26:26: error: unable to find numeric literal operator 'operator""s'
   26 | cout << format("{:%T}", -10'000s); // prints: -02:46:40
      |                          ^~~~~~~
p1437.cpp:26:26: note: use '-fext-numeric-literals' to enable more built-in suffixes
p1437.cpp:26:9: error: 'format' was not declared in this scope
   26 | cout << format("{:%T}", -10'000s); // prints: -02:46:40
      |         ^~~~~~
p1437.cpp:27:32: error: unable to find numeric literal operator 'operator""s'
   27 | cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40
      |                                ^~~~~~~
p1437.cpp:27:32: note: use '-fext-numeric-literals' to enable more built-in suffixes
p1437.cpp:28:56: error: unable to find numeric literal operator 'operator""s'
   28 | cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);// prints: minutes -46, hours 02, seconds 40
      |                                                        ^~~~~~~
p1437.cpp:28:56: note: use '-fext-numeric-literals' to enable more built-in suffixes
p1437.cpp: At global scope:
p1437.cpp:37:29: error: unable to find numeric literal operator 'operator""ms'
   37 | string s = format("{:=>8}", 42ms); // value of s is "====42ms"
      |                             ^~~~
p1437.cpp:37:29: note: use '-fext-numeric-literals' to enable more built-in suffixes
p1437.cpp:37:12: error: 'format' was not declared in this scope
   37 | string s = format("{:=>8}", 42ms); // value of s is "====42ms"
      |            ^~~~~~
p1437.cpp:39:8: error: 'formatter' is not a class template
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |        ^~~~~~~~~
p1437.cpp:39:26: error: 'sys_time' is not a member of 'std::chrono'
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |                          ^~~~~~~~
p1437.cpp:39:17: error: expected ';' before ',' token
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |                 ^                          ~
      |                 ;
p1437.cpp:42:10: error: 'formatter' is not a class template
   42 |   struct formatter<chrono::utc_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:42:28: error: 'utc_time' is not a member of 'std::chrono'
   42 |   struct formatter<chrono::utc_time<Duration>, charT>;
      |                            ^~~~~~~~
p1437.cpp:42:19: error: expected ';' before ',' token
   42 |   struct formatter<chrono::utc_time<Duration>, charT>;
      |                   ^                          ~
      |                   ;
p1437.cpp:45:10: error: 'formatter' is not a class template
   45 |   struct formatter<chrono::tai_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:45:28: error: 'tai_time' is not a member of 'std::chrono'
   45 |   struct formatter<chrono::tai_time<Duration>, charT>;
      |                            ^~~~~~~~
p1437.cpp:45:19: error: expected ';' before ',' token
   45 |   struct formatter<chrono::tai_time<Duration>, charT>;
      |                   ^                          ~
      |                   ;
p1437.cpp:48:10: error: 'formatter' is not a class template
   48 |   struct formatter<chrono::gps_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:48:28: error: 'gps_time' is not a member of 'std::chrono'
   48 |   struct formatter<chrono::gps_time<Duration>, charT>;
      |                            ^~~~~~~~
p1437.cpp:48:19: error: expected ';' before ',' token
   48 |   struct formatter<chrono::gps_time<Duration>, charT>;
      |                   ^                          ~
      |                   ;
p1437.cpp:51:10: error: 'formatter' is not a class template
   51 |   struct formatter<chrono::file_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:51:28: error: 'file_time' is not a member of 'std::chrono'
   51 |   struct formatter<chrono::file_time<Duration>, charT>;
      |                            ^~~~~~~~~
p1437.cpp:51:19: error: expected ';' before ',' token
   51 |   struct formatter<chrono::file_time<Duration>, charT>;
      |                   ^                           ~
      |                   ;
p1437.cpp:53:26: error: 'local' does not name a type; did you mean 'locale'?
   53 | template<class Duration> local-time-format-t <Duration>
      |                          ^~~~~
      |                          locale
p1437.cpp:58:10: error: 'formatter' is not a class template
   58 |   struct formatter<chrono::local_time<Duration>, charT>;
      |          ^~~~~~~~~
p1437.cpp:58:28: error: 'local_time' is not a member of 'std::chrono'
   58 |   struct formatter<chrono::local_time<Duration>, charT>;
      |                            ^~~~~~~~~~
p1437.cpp:58:19: error: expected ';' before ',' token
   58 |   struct formatter<chrono::local_time<Duration>, charT>;
      |                   ^                            ~
      |                   ;
p1437.cpp:60:38: error: expected unqualified-id before '-' token
   60 | template<class Duration> struct local-time-format-t {
      |                                      ^
p1437.cpp:67:8: error: 'formatter' is not a class template
   67 | struct formatter<chrono::local-time-format-t<Duration>, charT>;
      |        ^~~~~~~~~
p1437.cpp:67:8: error: 'std::chrono::formatter' is not a template
p1437.cpp:39:8: note: previous declaration here
   39 | struct formatter<chrono::sys_time<Duration>, charT>;
      |        ^~~~~~~~~
p1437.cpp:71:8: error: 'formatter' is not a class template
   71 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
      |        ^~~~~~~~~
p1437.cpp:71:26: error: 'zoned_time' is not a member of 'std::chrono'
   71 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
      |                          ^~~~~~~~~~
p1437.cpp:71:17: error: expected ';' before ',' token
   71 | struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
      |                 ^                                         ~
      |                 ;
p1437.cpp:79:26: error: 'zoned_time' in namespace 'std::chrono' does not name a template type
   79 |     format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
      |                          ^~~~~~~~~~
p1437.cpp:79:36: error: expected ',' or '...' before '<' token
   79 |     format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
      |                                    ^
p1437.cpp:81:1: error: 'sys_info' does not name a type; did you mean 'type_info'?
   81 | sys_info info = tp.get_info();
      | ^~~~~~~~
      | type_info
p1437.cpp:82:1: error: expected unqualified-id before 'return'
   82 | return formatter<chrono::local-time-format-t<Duration>, charT>::
      | ^~~~~~
p1437.cpp:83:73: error: expected unqualified-id before ',' token
   83 |                 format({tp.get_local_time(), &info.abbrev, &info.offset}, ctx);
      |                                                                         ^
p1437.cpp:83:78: error: expected constructor, destructor, or type conversion before ')' token
   83 |                 format({tp.get_local_time(), &info.abbrev, &info.offset}, ctx);
      |                                                                              ^

```

# 検討事項(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 箱庭　

箱庭もくもく会 #10 日時：2022/09/14(水) 17:30-19:30

https://hakoniwa.connpass.com/event/258129/


箱庭では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


# エンジニア夏休み企画

https://qiita.com/official-events/6d31965c499a69377c0b

個人開発と読書感想文に焦点を当てたのは良い企画だと思った。

## 個人開発

【個人開発】　効率的な背景　＜エンジニア夏休み企画＞

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

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

## 読書感想文

CコンパイラによるC言語規格の読書感想文として掲載しています。
コンパイル実験が、C++N4910に対する、G++とClang++による感想文だということご理解いただけると幸いです。

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

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


## 自己参考資料(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 初稿 　20220821