0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

32.8 Class template sub_match [re.submatch] C++N4910:2022 (703) p1641.cpp

Posted at

はじめに(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

bash
$ docker run -v /Users/ogawakiyoshi/n4910:/Users/ogawakiyoshi/n4910 -it kaizenjapan/n4910 /bin/bash

C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list

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.8 Class template sub_match [re.submatch] C++N4910:2022 (703) p1641.cpp

算譜(source code)

p1641.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 = "32.8 Class template sub_match [re.submatch] C++N4910:2022 (703) p1641.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.8.1 General [re.submatch.general]
// Class template sub_match denotes the sequence of characters matched by a particular marked sub-expression.
namespace std {
template<class BidirectionalIterator>
class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
public:
    using value_type      =
        typename iterator_traits<BidirectionalIterator>::value_type;
    using difference_type =
        typename iterator_traits<BidirectionalIterator>::difference_type;
    using iterator = BidirectionalIterator;
    using string_type = basic_string<value_type>;
    bool matched;
    constexpr sub_match();
    difference_type length() const;
    operator string_type() const;
    string_type str() const;
    int compare(const sub_match& s) const;
    int compare(const string_type& s) const;
    int compare(const value_type* s) const;
};
}
// 32.8.2 Members [re.submatch.members]
constexpr sub_match();
// Returns: matched ? distance(first, second) : 0.
operator string_type() const;
// Returns: matched ? string_type(first, second) : string_type().
string_type str() const;
// Returns: matched ? string_type(first, second) : string_type().
int compare(const sub_match& s) const;
// Returns: str().compare(s.str()).
int compare(const string_type& s) const;
// Returns: str().compare(s).
int compare(const value_type* s) const;
//Returns: str().compare(s).
// 32.8.3 Non-member operators [re.submatch.op]
//  Let SM-CAT(I) be
compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
        template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
// Returns: lhs.compare(rhs) == 0. template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
// Returns: static_cast<SM-CAT(BiIter)>(lhs.compare(rhs) <=> 0).
template<class BiIter, class ST, class SA>
bool operator==(
    const sub_match<BiIter>& lhs,
    const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
// Returns:
lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
template<class BiIter, class ST, class SA>
auto operator<=>(
    const sub_match<BiIter>& lhs,
    const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
// Returns:
static_cast<SM-CAT(BiIter)>(lhs.compare(
                                typename sub_match<BiIter>::string_type(rhs.data(), rhs.size()))
                            <=> 0 )
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs,
                const typename iterator_traits<BiIter>::value_type* rhs);
// Returns: lhs.compare(rhs) == 0.
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs,
                 const typename iterator_traits<BiIter>::value_type* rhs);
// Returns: static_cast<SM-CAT(BiIter)>(lhs.compare(rhs) <=> 0).
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs,
                const typename iterator_traits<BiIter>::value_type& rhs);
// Returns: lhs.compare(typename sub_match<BiIter>::string_type(1, rhs)) == 0.
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs,
// Returns:
                 const typename iterator_traits<BiIter>::value_type& rhs);
static_cast<SM-CAT(BiIter)>(lhs.compare(
                                typename sub_match<BiIter>::string_type(1, rhs))
                            <=> 0 )
template<class charT, class ST, class BiIter>
basic_ostream<charT, ST>&
operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
// Returns: os << m.str().
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}

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

bash
$ clang++ p1641.cpp -std=03 -o p1641l -I. -Wall
In file included from p1641.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 \
 ^
p1641.cpp:21:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
                   typename iterator_traits<BidirectionalIterator>::value_type;
                   ^
p1641.cpp:23:20: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
                   typename iterator_traits<BidirectionalIterator>::difference_type;
                   ^
p1641.cpp:24:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using iterator = BidirectionalIterator;
                 ^
p1641.cpp:25:21: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using string_type = basic_string<value_type>;
                    ^
p1641.cpp:27:1: error: unknown type name 'constexpr'
constexpr sub_match();
^
p1641.cpp:27:11: error: constructor cannot have a return type
constexpr sub_match();
          ^~~~~~~~~
p1641.cpp:36:1: error: unknown type name 'constexpr'
constexpr sub_match();
^
p1641.cpp:38:10: error: unknown type name 'string_type'
operator string_type() const;
         ^
p1641.cpp:40:1: error: unknown type name 'string_type'
string_type str() const;
^
p1641.cpp:40:19: error: non-member function cannot have 'const' qualifier
string_type str() const;
                  ^~~~~
p1641.cpp:42:19: error: use of class template 'sub_match' requires template arguments
int compare(const sub_match& s) const;
                  ^
p1641.cpp:18:16: note: template is declared here
         class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
               ^
p1641.cpp:42:33: error: non-member function cannot have 'const' qualifier
int compare(const sub_match& s) const;
                                ^~~~~
p1641.cpp:44:19: error: unknown type name 'string_type'
int compare(const string_type& s) const;
                  ^
p1641.cpp:44:35: error: non-member function cannot have 'const' qualifier
int compare(const string_type& s) const;
                                  ^~~~~
p1641.cpp:46:19: error: unknown type name 'value_type'; did you mean 'std::_Bit_const_iterator::value_type'?
int compare(const value_type* s) const;
                  ^~~~~~~~~~
                  std::_Bit_const_iterator::value_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator_base_types.h:132:26: note: 'std::_Bit_const_iterator::value_type' declared here
      typedef _Tp        value_type;
                         ^
p1641.cpp:46:34: error: non-member function cannot have 'const' qualifier
int compare(const value_type* s) const;
                                 ^~~~~
p1641.cpp:50:66: error: use of undeclared identifier 'I'
compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
                                                                 ^
p1641.cpp:52:81: error: expected '>'
     bool operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
                                                                                ^
p1641.cpp:50:27: note: to match this '<'
compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
                          ^
p1641.cpp:54:1: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
^
p1641.cpp:54:14: warning: '<=>' is a single token in C++20; add a space to avoid a change in behavior [-Wc++20-compat]
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
             ^
                
p1641.cpp:54:6: error: 'operator<=' cannot be the name of a variable or data member
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
     ^
p1641.cpp:54:16: error: expected ';' after top level declarator
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
               ^
               ;
p1641.cpp:61:1: error: unknown type name 'lhs'
lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
^
p1641.cpp:61:4: error: cannot use dot operator on a type
lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
   ^
p1641.cpp:63:16: warning: '<=>' is a single token in C++20; add a space to avoid a change in behavior [-Wc++20-compat]
  auto operator<=>(
               ^
                  
fatal error: too many errors emitted, stopping now [-ferror-limit=]
7 warnings and 20 errors generated.
$ clang++ p1641.cpp -std=2b -o p1641l -I. -Wall
p1641.cpp:36:11: error: deduction guide must be declared in the same scope as template 'std::sub_match'
constexpr sub_match();
          ^
p1641.cpp:18:16: note: template is declared here
         class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
               ^
p1641.cpp:36:11: error: deduction guide cannot be declared 'constexpr'
constexpr sub_match();
~~~~~~~~~ ^
p1641.cpp:36:11: error: deduction guide declaration without trailing return type
p1641.cpp:38:10: error: unknown type name 'string_type'
operator string_type() const;
         ^
p1641.cpp:40:1: error: unknown type name 'string_type'
string_type str() const;
^
p1641.cpp:40:19: error: non-member function cannot have 'const' qualifier
string_type str() const;
                  ^~~~~
p1641.cpp:42:19: error: use of class template 'sub_match' requires template arguments; argument deduction not allowed in function prototype
int compare(const sub_match& s) const;
                  ^~~~~~~~~
p1641.cpp:18:16: note: template is declared here
         class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
               ^
p1641.cpp:42:33: error: non-member function cannot have 'const' qualifier
int compare(const sub_match& s) const;
                                ^~~~~
p1641.cpp:44:19: error: unknown type name 'string_type'
int compare(const string_type& s) const;
                  ^
p1641.cpp:44:35: error: non-member function cannot have 'const' qualifier
int compare(const string_type& s) const;
                                  ^~~~~
p1641.cpp:46:19: error: unknown type name 'value_type'; did you mean 'false_type'?
int compare(const value_type* s) const;
                  ^~~~~~~~~~
                  false_type
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/type_traits:78:45: note: 'false_type' declared here
  typedef integral_constant<bool, false>    false_type;
                                            ^
p1641.cpp:46:34: error: non-member function cannot have 'const' qualifier
int compare(const value_type* s) const;
                                 ^~~~~
p1641.cpp:50:66: error: use of undeclared identifier 'I'
compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
                                                                 ^
p1641.cpp:51:4: error: expected unqualified-id
   template<class BiIter>
   ^
p1641.cpp:54:34: error: use of undeclared identifier 'BiIter'
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
                                 ^
p1641.cpp:54:64: error: use of undeclared identifier 'BiIter'
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
                                                               ^
p1641.cpp:61:1: error: unknown type name 'lhs'
lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
^
p1641.cpp:61:4: error: cannot use dot operator on a type
lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
   ^
p1641.cpp:67:1: error: expected unqualified-id
static_cast<SM-CAT(BiIter)>(lhs.compare(
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p1641.cpp -std=03 -o p1641g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1641.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 \
      |  ^~~~~
p1641.cpp:27:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   27 | constexpr sub_match();
      | ^~~~~~~~~
p1641.cpp:20:18: error: expected nested-name-specifier before 'value_type'
   20 |            using value_type      =
      |                  ^~~~~~~~~~
p1641.cpp:22:18: error: expected nested-name-specifier before 'difference_type'
   22 |            using difference_type =
      |                  ^~~~~~~~~~~~~~~
p1641.cpp:24:7: error: expected nested-name-specifier before 'iterator'
   24 | using iterator = BidirectionalIterator;
      |       ^~~~~~~~
p1641.cpp:25:7: error: expected nested-name-specifier before 'string_type'
   25 | using string_type = basic_string<value_type>;
      |       ^~~~~~~~~~~
p1641.cpp:27:1: error: 'constexpr' does not name a type
   27 | constexpr sub_match();
      | ^~~~~~~~~
p1641.cpp:27:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1641.cpp:28:7: error: 'difference_type' does not name a type
   28 |       difference_type length() const;
      |       ^~~~~~~~~~~~~~~
p1641.cpp:29:16: error: expected type-specifier before 'string_type'
   29 |       operator string_type() const;
      |                ^~~~~~~~~~~
p1641.cpp:30:7: error: 'string_type' does not name a type
   30 |       string_type str() const;
      |       ^~~~~~~~~~~
p1641.cpp:32:25: error: 'string_type' does not name a type
   32 |       int compare(const string_type& s) const;
      |                         ^~~~~~~~~~~
p1641.cpp:33:25: error: 'value_type' does not name a type
   33 |       int compare(const value_type* s) const;
      |                         ^~~~~~~~~~
p1641.cpp:36:1: error: 'constexpr' does not name a type
   36 | constexpr sub_match();
      | ^~~~~~~~~
p1641.cpp:36:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1641.cpp:38:10: error: expected type-specifier before 'string_type'
   38 | operator string_type() const;
      |          ^~~~~~~~~~~
p1641.cpp:40:1: error: 'string_type' does not name a type
   40 | string_type str() const;
      | ^~~~~~~~~~~
p1641.cpp:42:19: error: invalid use of template-name 'std::sub_match' without an argument list
   42 | int compare(const sub_match& s) const;
      |                   ^~~~~~~~~
p1641.cpp:42:19: note: class template argument deduction is only available with '-std=c++17' or '-std=gnu++17'
p1641.cpp:18:16: note: 'template<class BidirectionalIterator> class std::sub_match' declared here
   18 |          class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
      |                ^~~~~~~~~
p1641.cpp:42:33: error: non-member function 'int compare(const int&)' cannot have cv-qualifier
   42 | int compare(const sub_match& s) const;
      |                                 ^~~~~
p1641.cpp:44:19: error: 'string_type' does not name a type
   44 | int compare(const string_type& s) const;
      |                   ^~~~~~~~~~~
p1641.cpp:44:35: error: non-member function 'int compare(const int&)' cannot have cv-qualifier
   44 | int compare(const string_type& s) const;
      |                                   ^~~~~
p1641.cpp:46:19: error: 'value_type' does not name a type
   46 | int compare(const value_type* s) const;
      |                   ^~~~~~~~~~
p1641.cpp:46:34: error: non-member function 'int compare(const int*)' cannot have cv-qualifier
   46 | int compare(const value_type* s) const;
      |                                  ^~~~~
p1641.cpp:50:1: error: 'compare_three_way_result_t' does not name a type
   50 | compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
p1641.cpp:54:1: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      | ^~~~
      | ----
p1641.cpp:54:6: error: 'operator<=' does not name a type
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      |      ^~~~~~~~
p1641.cpp:61:1: error: 'lhs' does not name a type
   61 | lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
      | ^~~
p1641.cpp:67:1: error: expected unqualified-id before 'static_cast'
   67 | static_cast<SM-CAT(BiIter)>(lhs.compare(
      | ^~~~~~~~~~~
p1641.cpp:75:3: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
   75 |   auto operator<=>(const sub_match<BiIter>& lhs,
      |   ^~~~
      |   ----
p1641.cpp:75:8: error: 'operator<=' does not name a type
   75 |   auto operator<=>(const sub_match<BiIter>& lhs,
      |        ^~~~~~~~
p1641.cpp:83:3: warning: 'auto' changes meaning in C++11; please remove it [-Wc++11-compat]
   83 |   auto operator<=>(const sub_match<BiIter>& lhs,
      |   ^~~~
      |   ----
p1641.cpp:83:8: error: 'operator<=' does not name a type
   83 |   auto operator<=>(const sub_match<BiIter>& lhs,
      |        ^~~~~~~~
p1641.cpp:86:1: error: expected unqualified-id before 'static_cast'
   86 | static_cast<SM-CAT(BiIter)>(lhs.compare(
      | ^~~~~~~~~~~

$ g++ p1641.cpp -std=2b -o p1641g -I. -Wall
p1641.cpp:36:1: error: 'decl-specifier' in declaration of deduction guide
   36 | constexpr sub_match();
      | ^~~~~~~~~
p1641.cpp:36:11: error: deduction guide for 'std::sub_match<BidirectionalIterator>' must have trailing return type
   36 | constexpr sub_match();
      |           ^~~~~~~~~
p1641.cpp:18:16: note: 'template<class BidirectionalIterator> class std::sub_match' declared here
   18 |          class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
      |                ^~~~~~~~~
p1641.cpp:38:10: error: expected type-specifier before 'string_type'
   38 | operator string_type() const;
      |          ^~~~~~~~~~~
p1641.cpp:40:1: error: 'string_type' does not name a type
   40 | string_type str() const;
      | ^~~~~~~~~~~
p1641.cpp:42:13: error: template placeholder type 'const sub_match<...auto...>' must be followed by a simple declarator-id
   42 | int compare(const sub_match& s) const;
      |             ^~~~~
p1641.cpp:18:16: note: 'template<class BidirectionalIterator> class std::sub_match' declared here
   18 |          class sub_match : public pair<BidirectionalIterator, BidirectionalIterator> {
      |                ^~~~~~~~~
p1641.cpp:42:33: error: non-member function 'int compare(...)' cannot have cv-qualifier
   42 | int compare(const sub_match& s) const;
      |                                 ^~~~~
p1641.cpp:44:19: error: 'string_type' does not name a type
   44 | int compare(const string_type& s) const;
      |                   ^~~~~~~~~~~
p1641.cpp:44:35: error: non-member function 'int compare(const int&)' cannot have cv-qualifier
   44 | int compare(const string_type& s) const;
      |                                   ^~~~~
p1641.cpp:46:19: error: 'value_type' does not name a type
   46 | int compare(const value_type* s) const;
      |                   ^~~~~~~~~~
p1641.cpp:46:34: error: non-member function 'int compare(const int*)' cannot have cv-qualifier
   46 | int compare(const value_type* s) const;
      |                                  ^~~~~
p1641.cpp:50:66: error: 'I' was not declared in this scope
   50 | compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
      |                                                                  ^
p1641.cpp:50:67: error: template argument 1 is invalid
   50 | compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
      |                                                                   ^
p1641.cpp:50:70: error: template argument 1 is invalid
   50 | compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
      |                                                                      ^~~~~~~~~~
p1641.cpp:50:70: error: template argument 2 is invalid
p1641.cpp:50:70: error: template argument 3 is invalid
p1641.cpp:50:80: error: template argument 1 is invalid
   50 | compare_three_way_result_t<basic_string<typename iterator_traits<I>::value_type>>
      |                                                                                ^~
p1641.cpp:50:80: error: template argument 2 is invalid
p1641.cpp:51:4: error: expected unqualified-id before 'template'
   51 |    template<class BiIter>
      |    ^~~~~~~~
p1641.cpp:54:34: error: 'BiIter' was not declared in this scope
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      |                                  ^~~~~~
p1641.cpp:54:40: error: template argument 1 is invalid
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      |                                        ^
p1641.cpp:54:64: error: 'BiIter' was not declared in this scope
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      |                                                                ^~~~~~
p1641.cpp:54:70: error: template argument 1 is invalid
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      |                                                                      ^
p1641.cpp:54:6: error: 'auto operator<=>(const int&, const int&)' must have an argument of class or enumerated type
   54 | auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
      |      ^~~~~~~~
p1641.cpp:61:1: error: 'lhs' does not name a type
   61 | lhs.compare(typename sub_match<BiIter>::string_type(rhs.data(), rhs.size())) == 0
      | ^~~
p1641.cpp:67:1: error: expected unqualified-id before 'static_cast'
   67 | static_cast<SM-CAT(BiIter)>(lhs.compare(
      | ^~~~~~~~~~~
p1641.cpp:86:1: error: expected unqualified-id before 'static_cast'
   86 | static_cast<SM-CAT(BiIter)>(lhs.compare(
      | ^~~~~~~~~~~

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

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?