はじめに(Introduction)
N4910 Working Draft, Standard for Programming Language C++
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++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに1回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。
この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を10種類以上、最近になって解決できたことがあります。それは、主に次の3つの情報に基づいています。
cpprefjp - C++日本語リファレンス
コンパイラの実装状況
また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。
作業方針(sequence)
Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの2種類
でコンパイルし、
1)コンパイルエラーを収集する。
2)コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
3)リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
4)意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。
1)だけのものから4)まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。
C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
$ 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
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++
読書感想文
CコンパイラによるC言語規格の読書感想文として掲載しています。
コンパイル実験が、C++N4910に対する、G++とClang++による感想文だということご理解いただけると幸いです。
読書感想文は人間かAIだけが作るものとは限りません。
本(電子書籍を含む)を入力として、その内容に対する文字列を読書感想文として受け止めましょう。
元の文章をあり方、コンパイルできるように電子化しておくこと、コンパイラが解釈可能な断片の作り方など。
個人開発
Cコンパイラの試験を一人でもくもくとやっているのは個人開発の一つの姿です。
<この項は書きかけです。順次追記します。>
編纂器(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.
32.10 Regular expression algorithms [re.alg] C++N4910:2022 (705) p1648.cpp
算譜(source code)
// 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 = "32.10 Regular expression algorithms [re.alg] C++N4910:2022 (705) p1648.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;
// 32.10.1 Exceptions [re.except]
// The algorithms described in subclause 32.10 may throw an exception of type regex_error. If such an exception e is thrown, e.code() shall return either regex_constants::error_complexity or regex_- constants::error_stack.
// 32.10.2 regex_match [re.alg.match]
template<class BidirectionalIterator, class Allocator, class charT, class traits>
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
// [Example 1:
std::regex re("Get|GetValue");
std::cmatch m;
regex_search("GetValue", m, re);
regex_match ("GetValue", m, re);
regex_search("GetValues", m, re);
regex_match ("GetValues", m, re);
// returns true, and m[0] contains "Get"
// returns true, and m[0] contains "GetValue" // returns true, and m[0] contains "Get"
// returns false
// Element Value
// m.size() 1 + e.mark_count()
// m.empty() false
// m.prefix().first first
// m.prefix().second first
// m.prefix().matched false
// m.suffix().first last
// m.suffix().second last
// m.suffix().matched false
// m[0].first first
// m[0].second last
// m[0].matched true
// m[n].first For all integers 0 < n < m.size(), the start of the se- quence that matched sub-expression n. Alternatively, if sub-expression n did not participate in the match, then last.
template<class BidirectionalIterator, class charT, class traits>
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Effects: Behaves “as if” by constructing an instance of match_results<BidirectionalIterator> what, and then returning the result of regex_match(first, last, what, e, flags).
// Table 138: Effects of regex_match algorithm (continued)
// Element Value m[n].second For all integers 0 < n < m.size(), the end of the se-quence that matched sub-expression n. Alternatively, if sub-expression n did not participate in the match, then last. m[n].matched For all integers 0 < n < m.size(), true if sub-expression n participated in the match, false otherwise.
template<class charT, class Allocator, class traits>
bool regex_match(const charT* str,
match_results<const charT*, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_match(str, str + char_traits<charT>::length(str), m, e, flags).
template<class ST, class SA, class Allocator, class charT, class traits>
bool regex_match(const basic_string<charT, ST, SA>& s,
match_results<typename basic_string<charT, ST, SA>::const_iterator,
Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_match(s.begin(), s.end(), m, e, flags).
template<class charT, class traits>
bool regex_match(const charT* str,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_match(str, str + char_traits<charT>::length(str), e, flags)
template<class ST, class SA, class charT, class traits>
bool regex_match(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_match(s.begin(), s.end(), e, flags).
// 32.10.3 regex_search [re.alg.search]
template<class BidirectionalIterator, class Allocator, class charT, class traits>
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
match_results<BidirectionalIterator, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Preconditions: BidirectionalIterator meets the Cpp17BidirectionalIterator requirements (25.3.5.6).
// Effects: Determines whether there is some sub-sequence within [first, last) that matches the regular expression e. The parameter flags is used to control how the expression is matched against the character sequence. Returns true if such a sequence exists, false otherwise.
// Postconditions: m.ready() == true in all cases. If the function returns false, then the effect on parameter m is unspecified except that m.size() returns 0 and m.empty() returns true. Otherwise the effects on parameter m are given in Table 139.
template<class charT, class Allocator, class traits>
bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_search(str, str + char_traits<charT>::length(str), m, e, flags).
// Table 139: Effects of regex_search algorithm [tab:re.alg.search]
// Element Value
// m.size() 1 + e.mark_count()
// m.empty() false
// m.prefix().first first
// m.prefix().second m[0].first
// m.prefix().matched m.prefix().first != m.prefix().second
// m.suffix().first m[0].second
// m.suffix().second last
// m.suffix().matched m.suffix().first != m.suffix().second
// m[0].first The start of the sequence of characters that matched the regular expression
// m[0].second The end of the sequence of characters that matched the regular expression
// m[0].matched true
// m[n].first For all integers 0 < n < m.size(), the start of the se- quence that matched sub-expression n. Alternatively, if sub-expression n did not participate in the match, then last.
// m[n].second For all integers 0 < n < m.size(), the end of the se- quence that matched sub-expression n. Alternatively, if sub-expression n did not participate in the match, then last.
// m[n].matched For all integers 0 < n < m.size(), true if sub-expression n participated in the match, false otherwise.
template<class ST, class SA, class Allocator, class charT, class traits>
bool regex_search(const basic_string<charT, ST, SA>& s,
match_results<typename basic_string<charT, ST, SA>::const_iterator,
Allocator>& m,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_search(s.begin(), s.end(), m, e, flags).
template<class BidirectionalIterator, class charT, class traits>
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Effects: Behaves “as if” by constructing an object what of type match_results<Bidirectional- Iterator> and returning regex_search(first, last, what, e, flags).
template<class charT, class traits>
bool regex_search(const charT* str,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_search(str, str + char_traits<charT>::length(str), e, flags).
template<class ST, class SA, class charT, class traits>
bool regex_search(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Returns: regex_search(s.begin(), s.end(), e, flags).
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class OutputIterator, class BidirectionalIterator, class traits, class charT>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Effects: Constructs a regex_iterator object i as if by regex_iterator<BidirectionalIterator, charT, traits> i(first, last, e, flags) and uses i to enumerate through all of the matches m of type match_results<BidirectionalIterator> that occur within the sequence [first, last). If no such matches are found and !(flags & regex_- constants::format_no_copy), then calls out = copy(first, last, out)
// If any matches are found then, for each such match:
// — If !(flags & regex_constants::format_no_copy), calls out = copy(m.prefix().first, m.prefix().second, out)
// — Then calls out = m.format(out, fmt, flags) for the first form of the function and out = m.format(out, fmt, fmt + char_traits<charT>::length(fmt), flags) for the second.
// Finally, if such a match is found and !(flags & regex_constants::format_no_copy), calls out = copy(last_m.suffix().first, last_m.suffix().second, out) where last_m is a copy of the last match found. If flags & regex_constants::format_first_only is nonzero, then only the first match found is replaced.
// Returns: out.
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Effects: Constructs an empty string result of type basic_string<charT, ST, SA> and calls:
regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt, flags);
// Returns: result.
// 32.10.4 regex_replace [re.alg.replace]
template<class OutputIterator, class BidirectionalIterator,
class traits, class charT, class ST, class SA>
OutputIterator
regex_replace(OutputIterator out,
template<class traits, class charT, class ST, class SA, class FST, class FSA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const basic_string<charT, FST, FSA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA>
template<class traits, class charT, class ST, class SA>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
// Effects: Constructs an empty string result of type basic_string<charT> and calls: regex_replace(back_inserter(result), s, s + char_traits<charT>::length(s), e, fmt, flags);
// Returns: result.
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p1648.cpp -std=03 -o p1648l -I. -Wall
In file included from p1648.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 \
^
p1648.cpp:20:8: error: no type named 'regex' in namespace 'std'
std::regex re("Get|GetValue");
~~~~~^
p1648.cpp:20:17: error: expected parameter declarator
std::regex re("Get|GetValue");
^
p1648.cpp:20:17: error: expected ')'
p1648.cpp:20:16: note: to match this '('
std::regex re("Get|GetValue");
^
p1648.cpp:20:32: error: expected ')'
std::regex re("Get|GetValue");
^
p1648.cpp:18:19: note: to match this '('
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
^
p1648.cpp:21:8: error: no type named 'cmatch' in namespace 'std'
std::cmatch m;
~~~~~^
p1648.cpp:22:3: error: C++ requires a type specifier for all declarations
regex_search("GetValue", m, re);
^
p1648.cpp:22:31: error: use of undeclared identifier 're'
regex_search("GetValue", m, re);
^
p1648.cpp:23:3: error: C++ requires a type specifier for all declarations
regex_match ("GetValue", m, re);
^
p1648.cpp:23:31: error: use of undeclared identifier 're'
regex_match ("GetValue", m, re);
^
p1648.cpp:24:3: error: C++ requires a type specifier for all declarations
regex_search("GetValues", m, re);
^
p1648.cpp:24:32: error: use of undeclared identifier 're'
regex_search("GetValues", m, re);
^
p1648.cpp:25:3: error: C++ requires a type specifier for all declarations
regex_match ("GetValues", m, re);
^
p1648.cpp:25:32: error: use of undeclared identifier 're'
regex_match ("GetValues", m, re);
^
p1648.cpp:44:26: error: no template named 'basic_regex'
const basic_regex<charT, traits>& e,
^
p1648.cpp:45:20: error: use of undeclared identifier 'regex_constants'
regex_constants::match_flag_type flags = regex_constants::match_default);
^
p1648.cpp:45:61: error: use of undeclared identifier 'regex_constants'
regex_constants::match_flag_type flags = regex_constants::match_default);
^
p1648.cpp:51:15: error: no template named 'match_results'
match_results<const charT*, Allocator>& m,
^
p1648.cpp:52:21: error: no template named 'basic_regex'
const basic_regex<charT, traits>& e,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ clang++ p1648.cpp -std=2b -o p1648l -I. -Wall
p1648.cpp:20:8: error: no type named 'regex' in namespace 'std'
std::regex re("Get|GetValue");
~~~~~^
p1648.cpp:20:17: error: expected parameter declarator
std::regex re("Get|GetValue");
^
p1648.cpp:20:17: error: expected ')'
p1648.cpp:20:16: note: to match this '('
std::regex re("Get|GetValue");
^
p1648.cpp:20:32: error: expected ')'
std::regex re("Get|GetValue");
^
p1648.cpp:18:19: note: to match this '('
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
^
p1648.cpp:21:8: error: no type named 'cmatch' in namespace 'std'
std::cmatch m;
~~~~~^
p1648.cpp:22:3: error: no template named 'regex_search'; did you mean 'regex_match'?
regex_search("GetValue", m, re);
^~~~~~~~~~~~
regex_match
p1648.cpp:18:8: note: 'regex_match' declared here
bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
^
p1648.cpp:22:3: error: C++ requires a type specifier for all declarations
regex_search("GetValue", m, re);
^
p1648.cpp:22:31: error: use of undeclared identifier 're'
regex_search("GetValue", m, re);
^
p1648.cpp:23:3: error: C++ requires a type specifier for all declarations
regex_match ("GetValue", m, re);
^
p1648.cpp:23:31: error: use of undeclared identifier 're'
regex_match ("GetValue", m, re);
^
p1648.cpp:24:3: error: C++ requires a type specifier for all declarations
regex_search("GetValues", m, re);
^
p1648.cpp:24:32: error: use of undeclared identifier 're'
regex_search("GetValues", m, re);
^
p1648.cpp:25:3: error: C++ requires a type specifier for all declarations
regex_match ("GetValues", m, re);
^
p1648.cpp:25:32: error: use of undeclared identifier 're'
regex_match ("GetValues", m, re);
^
p1648.cpp:44:26: error: no template named 'basic_regex'
const basic_regex<charT, traits>& e,
^
p1648.cpp:45:20: error: use of undeclared identifier 'regex_constants'
regex_constants::match_flag_type flags = regex_constants::match_default);
^
p1648.cpp:45:61: error: use of undeclared identifier 'regex_constants'
regex_constants::match_flag_type flags = regex_constants::match_default);
^
p1648.cpp:51:15: error: no template named 'match_results'
match_results<const charT*, Allocator>& m,
^
p1648.cpp:52:21: error: no template named 'basic_regex'
const basic_regex<charT, traits>& e,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p1648.cpp -std=03 -o p1648g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from N4910.h:11,
from p1648.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 \
| ^~~~~
p1648.cpp:20:8: error: 'std::regex' has not been declared
20 | std::regex re("Get|GetValue");
| ^~~~~
p1648.cpp:20:16: error: expected ',' or '...' before '(' token
20 | std::regex re("Get|GetValue");
| ^
p1648.cpp:20:32: error: expected ')' before ';' token
20 | std::regex re("Get|GetValue");
| ^
| )
p1648.cpp:18:19: note: to match this '('
18 | bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
| ^
p1648.cpp:21:8: error: 'cmatch' in namespace 'std' does not name a type; did you mean 'mismatch'?
21 | std::cmatch m;
| ^~~~~~
| mismatch
p1648.cpp:22:15: error: expected constructor, destructor, or type conversion before '(' token
22 | regex_search("GetValue", m, re);
| ^
p1648.cpp:23:15: error: expected constructor, destructor, or type conversion before '(' token
23 | regex_match ("GetValue", m, re);
| ^
p1648.cpp:24:15: error: expected constructor, destructor, or type conversion before '(' token
24 | regex_search("GetValues", m, re);
| ^
p1648.cpp:25:15: error: expected constructor, destructor, or type conversion before '(' token
25 | regex_match ("GetValues", m, re);
| ^
p1648.cpp:44:26: error: 'basic_regex' does not name a type
44 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:44:37: error: expected ',' or '...' before '<' token
44 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:51:15: error: 'match_results' has not been declared
51 | match_results<const charT*, Allocator>& m,
| ^~~~~~~~~~~~~
p1648.cpp:51:28: error: expected ',' or '...' before '<' token
51 | match_results<const charT*, Allocator>& m,
| ^
p1648.cpp:57:15: error: 'match_results' has not been declared
57 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^~~~~~~~~~~~~
p1648.cpp:57:28: error: expected ',' or '...' before '<' token
57 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^
p1648.cpp:64:21: error: 'basic_regex' does not name a type
64 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:64:32: error: expected ',' or '...' before '<' token
64 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:69:26: error: 'basic_regex' does not name a type
69 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:69:37: error: expected ',' or '...' before '<' token
69 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:75:16: error: 'match_results' has not been declared
75 | match_results<BidirectionalIterator, Allocator>& m,
| ^~~~~~~~~~~~~
p1648.cpp:75:29: error: expected ',' or '...' before '<' token
75 | match_results<BidirectionalIterator, Allocator>& m,
| ^
p1648.cpp:82:39: error: 'match_results' has not been declared
82 | bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
| ^~~~~~~~~~~~~
p1648.cpp:82:52: error: expected ',' or '...' before '<' token
82 | bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
| ^
p1648.cpp:104:16: error: 'match_results' has not been declared
104 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^~~~~~~~~~~~~
p1648.cpp:104:29: error: expected ',' or '...' before '<' token
104 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^
p1648.cpp:111:22: error: 'basic_regex' does not name a type
111 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:111:33: error: expected ',' or '...' before '<' token
111 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:116:22: error: 'basic_regex' does not name a type
116 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:116:33: error: expected ',' or '...' before '<' token
116 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:121:27: error: 'basic_regex' does not name a type
121 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:121:38: error: expected ',' or '...' before '<' token
121 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:124:19: error: 'BidirectionalIterator' does not name a type
124 | BidirectionalIterator first, BidirectionalIterator last,
| ^~~~~~~~~~~~~~~~~~~~~
p1648.cpp:132:25: error: 'basic_regex' does not name a type
132 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:132:36: error: expected ',' or '...' before '<' token
132 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:141:14: error: 'charT' was not declared in this scope; did you mean 'char'?
141 | basic_string<charT, ST, SA>
| ^~~~~
| char
p1648.cpp:141:21: error: 'ST' was not declared in this scope
141 | basic_string<charT, ST, SA>
| ^~
p1648.cpp:141:25: error: 'SA' was not declared in this scope
141 | basic_string<charT, ST, SA>
| ^~
p1648.cpp:141:27: error: template argument 1 is invalid
141 | basic_string<charT, ST, SA>
| ^
p1648.cpp:141:27: error: template argument 2 is invalid
p1648.cpp:141:27: error: template argument 3 is invalid
p1648.cpp:142:36: error: 'charT' was not declared in this scope; did you mean 'char'?
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^~~~~
| char
p1648.cpp:142:43: error: 'ST' was not declared in this scope
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^~
p1648.cpp:142:47: error: 'SA' was not declared in this scope
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^~
p1648.cpp:142:49: error: template argument 1 is invalid
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^
p1648.cpp:142:49: error: template argument 2 is invalid
p1648.cpp:142:49: error: template argument 3 is invalid
p1648.cpp:143:23: error: 'basic_regex' does not name a type
143 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:143:34: error: expected ',' or '...' before '<' token
143 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:147:14: error: expected constructor, destructor, or type conversion before '(' token
147 | regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt, flags);
| ^
p1648.cpp:154:1: error: expected identifier before 'template'
154 | template<class traits, class charT, class ST, class SA, class FST, class FSA>
| ^~~~~~~~
p1648.cpp:154:1: error: expected ',' or '...' before 'template'
p1648.cpp:159:91: error: expected ')' before ';' token
159 | regex_constants::match_flag_type flags = regex_constants::match_default);
| ^
| )
p1648.cpp:153:18: note: to match this '('
153 | regex_replace(OutputIterator out,
| ^
p1648.cpp:161:10: error: declaration of template parameter 'traits' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:10: note: template parameter 'traits' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:161:24: error: declaration of template parameter 'charT' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:24: note: template parameter 'charT' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:161:37: error: declaration of template parameter 'ST' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:37: note: template parameter 'ST' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:161:47: error: declaration of template parameter 'SA' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:47: note: template parameter 'SA' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:164:25: error: 'basic_regex' does not name a type
164 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:164:36: error: expected ',' or '...' before '<' token
164 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:163:5: error: too many template-parameter-lists
163 | regex_replace(const charT* s,
| ^~~~~~~~~~~~~
p1648.cpp:170:25: error: 'basic_regex' does not name a type
170 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:170:36: error: expected ',' or '...' before '<' token
170 | const basic_regex<charT, traits>& e,
| ^
$ g++ p1648.cpp -std=2b -o p1648g -I. -Wall
p1648.cpp:20:3: error: 'std::regex' has not been declared
20 | std::regex re("Get|GetValue");
| ^~~
p1648.cpp:20:16: error: expected ',' or '...' before '(' token
20 | std::regex re("Get|GetValue");
| ^
p1648.cpp:20:32: error: expected ')' before ';' token
20 | std::regex re("Get|GetValue");
| ^
| )
p1648.cpp:18:19: note: to match this '('
18 | bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
| ^
p1648.cpp:21:8: error: 'cmatch' in namespace 'std' does not name a type; did you mean 'mismatch'?
21 | std::cmatch m;
| ^~~~~~
| mismatch
p1648.cpp:22:15: error: expected constructor, destructor, or type conversion before '(' token
22 | regex_search("GetValue", m, re);
| ^
p1648.cpp:23:15: error: expected constructor, destructor, or type conversion before '(' token
23 | regex_match ("GetValue", m, re);
| ^
p1648.cpp:24:15: error: expected constructor, destructor, or type conversion before '(' token
24 | regex_search("GetValues", m, re);
| ^
p1648.cpp:25:15: error: expected constructor, destructor, or type conversion before '(' token
25 | regex_match ("GetValues", m, re);
| ^
p1648.cpp:44:26: error: 'basic_regex' does not name a type
44 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:44:37: error: expected ',' or '...' before '<' token
44 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:51:15: error: 'match_results' has not been declared
51 | match_results<const charT*, Allocator>& m,
| ^~~~~~~~~~~~~
p1648.cpp:51:28: error: expected ',' or '...' before '<' token
51 | match_results<const charT*, Allocator>& m,
| ^
p1648.cpp:57:15: error: 'match_results' has not been declared
57 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^~~~~~~~~~~~~
p1648.cpp:57:28: error: expected ',' or '...' before '<' token
57 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^
p1648.cpp:64:21: error: 'basic_regex' does not name a type
64 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:64:32: error: expected ',' or '...' before '<' token
64 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:69:26: error: 'basic_regex' does not name a type
69 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:69:37: error: expected ',' or '...' before '<' token
69 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:75:16: error: 'match_results' has not been declared
75 | match_results<BidirectionalIterator, Allocator>& m,
| ^~~~~~~~~~~~~
p1648.cpp:75:29: error: expected ',' or '...' before '<' token
75 | match_results<BidirectionalIterator, Allocator>& m,
| ^
p1648.cpp:82:39: error: 'match_results' has not been declared
82 | bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
| ^~~~~~~~~~~~~
p1648.cpp:82:52: error: expected ',' or '...' before '<' token
82 | bool regex_search(const charT* str, match_results<const charT*, Allocator>& m,
| ^
p1648.cpp:104:16: error: 'match_results' has not been declared
104 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^~~~~~~~~~~~~
p1648.cpp:104:29: error: expected ',' or '...' before '<' token
104 | match_results<typename basic_string<charT, ST, SA>::const_iterator,
| ^
p1648.cpp:111:22: error: 'basic_regex' does not name a type
111 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:111:33: error: expected ',' or '...' before '<' token
111 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:116:22: error: 'basic_regex' does not name a type
116 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:116:33: error: expected ',' or '...' before '<' token
116 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:121:27: error: 'basic_regex' does not name a type
121 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:121:38: error: expected ',' or '...' before '<' token
121 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:124:19: error: 'BidirectionalIterator' does not name a type
124 | BidirectionalIterator first, BidirectionalIterator last,
| ^~~~~~~~~~~~~~~~~~~~~
p1648.cpp:132:25: error: 'basic_regex' does not name a type
132 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:132:36: error: expected ',' or '...' before '<' token
132 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:141:14: error: 'charT' was not declared in this scope; did you mean 'char'?
141 | basic_string<charT, ST, SA>
| ^~~~~
| char
p1648.cpp:141:21: error: 'ST' was not declared in this scope
141 | basic_string<charT, ST, SA>
| ^~
p1648.cpp:141:25: error: 'SA' was not declared in this scope
141 | basic_string<charT, ST, SA>
| ^~
p1648.cpp:141:27: error: template argument 1 is invalid
141 | basic_string<charT, ST, SA>
| ^
p1648.cpp:141:27: error: template argument 2 is invalid
p1648.cpp:141:27: error: template argument 3 is invalid
p1648.cpp:142:36: error: 'charT' was not declared in this scope; did you mean 'char'?
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^~~~~
| char
p1648.cpp:142:43: error: 'ST' was not declared in this scope
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^~
p1648.cpp:142:47: error: 'SA' was not declared in this scope
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^~
p1648.cpp:142:49: error: template argument 1 is invalid
142 | regex_replace(const basic_string<charT, ST, SA>& s,
| ^
p1648.cpp:142:49: error: template argument 2 is invalid
p1648.cpp:142:49: error: template argument 3 is invalid
p1648.cpp:143:35: error: 'charT' was not declared in this scope; did you mean 'char'?
143 | const basic_regex<charT, traits>& e,
| ^~~~~
| char
p1648.cpp:143:42: error: 'traits' was not declared in this scope
143 | const basic_regex<charT, traits>& e,
| ^~~~~~
p1648.cpp:143:35: error: 'charT' was not declared in this scope; did you mean 'char'?
143 | const basic_regex<charT, traits>& e,
| ^~~~~
| char
p1648.cpp:143:42: error: 'traits' was not declared in this scope
143 | const basic_regex<charT, traits>& e,
| ^~~~~~
p1648.cpp:143:35: error: 'charT' was not declared in this scope; did you mean 'char'?
143 | const basic_regex<charT, traits>& e,
| ^~~~~
| char
p1648.cpp:143:42: error: 'traits' was not declared in this scope
143 | const basic_regex<charT, traits>& e,
| ^~~~~~
p1648.cpp:143:35: error: 'charT' was not declared in this scope; did you mean 'char'?
143 | const basic_regex<charT, traits>& e,
| ^~~~~
| char
p1648.cpp:143:42: error: 'traits' was not declared in this scope
143 | const basic_regex<charT, traits>& e,
| ^~~~~~
p1648.cpp:143:35: error: 'charT' was not declared in this scope; did you mean 'char'?
143 | const basic_regex<charT, traits>& e,
| ^~~~~
| char
p1648.cpp:143:42: error: 'traits' was not declared in this scope
143 | const basic_regex<charT, traits>& e,
| ^~~~~~
p1648.cpp:143:35: error: 'charT' was not declared in this scope; did you mean 'char'?
143 | const basic_regex<charT, traits>& e,
| ^~~~~
| char
p1648.cpp:143:42: error: 'traits' was not declared in this scope
143 | const basic_regex<charT, traits>& e,
| ^~~~~~
p1648.cpp:143:23: error: 'basic_regex' does not name a type
143 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:143:34: error: expected ',' or '...' before '<' token
143 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:147:14: error: expected constructor, destructor, or type conversion before '(' token
147 | regex_replace(back_inserter(result), s.begin(), s.end(), e, fmt, flags);
| ^
p1648.cpp:154:1: error: expected identifier before 'template'
154 | template<class traits, class charT, class ST, class SA, class FST, class FSA>
| ^~~~~~~~
p1648.cpp:154:1: error: expected ',' or '...' before 'template'
p1648.cpp:159:91: error: expected ')' before ';' token
159 | regex_constants::match_flag_type flags = regex_constants::match_default);
| ^
| )
p1648.cpp:153:18: note: to match this '('
153 | regex_replace(OutputIterator out,
| ^
p1648.cpp:161:10: error: declaration of template parameter 'traits' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:10: note: template parameter 'traits' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:161:24: error: declaration of template parameter 'charT' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:24: note: template parameter 'charT' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:161:37: error: declaration of template parameter 'ST' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:37: note: template parameter 'ST' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:161:47: error: declaration of template parameter 'SA' shadows template parameter
161 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:160:47: note: template parameter 'SA' declared here
160 | template<class traits, class charT, class ST, class SA>
| ^~~~~
p1648.cpp:164:25: error: 'basic_regex' does not name a type
164 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:164:36: error: expected ',' or '...' before '<' token
164 | const basic_regex<charT, traits>& e,
| ^
p1648.cpp:163:5: error: too many template-parameter-lists
163 | regex_replace(const charT* s,
| ^~~~~~~~~~~~~
p1648.cpp:170:25: error: 'basic_regex' does not name a type
170 | const basic_regex<charT, traits>& e,
| ^~~~~~~~~~~
p1648.cpp:170:36: error: expected ',' or '...' before '<' token
170 | const basic_regex<charT, traits>& e,
| ^
検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。
応用例1 AUTOSAR C++
AUTOSARでC++のコーディング標準を作っている。
MISRA-C++コーディング標準の改訂をまたずに、C++14に対応したかったためかもしれない。
Autosar Guidelines C++14 example code compile list
MISRA C++, AUTOSAR C++について
応用例2 MISRA C/C++
MISRA C まとめ #include
MISRA C++ 5-0-16
応用例3 CERT C/C++
SEI CERT C++ Coding Standard AA. Bibliography 確認中。
MISRA C/C++, AUTOSAR C++, CERT C/C++とC/C++工業標準をコンパイルする
応用例4 箱庭
箱庭もくもく会
第11回 未定
箱庭ではUnityをはじめC++を使っているらしい。
ここでコンパイルしたコードと同じようなコードを使っているか、
ここで出たコンパイルエラーと同じようなエラーがでたかを
いろいろな版のコンパイラでコンパイルして確認していく。
この項目は、箱庭プロジェクトを市場分析の対象として、原則的には、箱庭プロジェクトの外部から分析し、外部から箱庭の広告宣伝のための戦略会議を仮想した結果、仮想「箱庭もくもく会」を開催してみることを企画するものである。
一切の内容は、箱庭プロジェクト、Athrill, TOPPERSとは無関係である。
一(いち)参加データアナリストの、個人的なつぶやきです。
仮想戦略会議「箱庭」
お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる(1)
お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる(2)
自己参考資料(self reference)
関連する自己参照以外は、こちらの先頭に移転。
C言語(C++)に対する誤解、曲解、無理解、爽快。
#include "N4910.h"
C++N4910資料の改善点
dockerにclang
docker gnu(gcc/g++) and llvm(clang/clang++)
コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
C++N4910:2022 tag follower 300人超えました。ありがとうございます。
astyle 使ってみた
<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
文書履歴(document history)
ver. 0.01 初稿 20220920