はじめに(Introduction)
N4910 Working Draft, Standard for Programming Language C++
n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 WG21では、可能な限り作業文書を公開し、幅広い意見を求めています。
一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, TOPPERSカーネル、g++(GCC), clang++(LLVM)との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。
<この項は書きかけです。順次追記します。>
背景(back ground)
C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに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
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++
編纂器(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.
26.4 Range requirements [range.req] C++N4910:2022 (652) p1038.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 = "26.4 Range requirements [range.req] C++N4910:2022 (652) p1038.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;
// 26.4.1 General [range.req.general]
// Ranges are an abstraction that allow a C++ program to operate on elements of data structures uniformly. Call- ing ranges::begin on a range returns an object whose type models input_or_output_iterator (25.3.4.6). Calling ranges::end on a range returns an object whose type S, together with the type I of the object returned by ranges::begin, models sentinel_for<S, I>. The library formalizes the interfaces, semantics, and complexity of ranges to enable algorithms and range adaptors that work efficiently on different types of sequences.
// The range concept requires that ranges::begin and ranges::end return an iterator and a sentinel, respec- tively. The sized_range concept refines range with the requirement that ranges::size be amortized O(1). The view concept specifies requirements on a range type to provide operations with predictable complexity.
// Several refinements of range group requirements that arise frequently in concepts and algorithms. Common ranges are ranges for which ranges::begin and ranges::end return objects of the same type. Random access ranges are ranges for which ranges::begin returns a type that models random_access_iterator (25.3.4.13).
// (Contiguous, bidirectional, forward, input, and output ranges are defined similarly.) Viewable ranges can be converted to views.
// 26.4.2 Ranges [range.range]
// The range concept defines the requirements of a type that allows iteration over its elements by providing an iterator and sentinel that denote the elements of the range.
// The required expressions ranges::begin(t) and ranges::end(t) of the range concept do not require implicit expression variations (18.2).
template<class T>
concept range =
requires(T& t) {
ranges::begin(t);
ranges::end(t);
};
// sometimes equality-preserving (see below)
// Given an expression t such that decltype((t)) is T&, T models range only if
// [range.prim.cdata]
range<T> && requires(T& t) {
ranges::size(t);
};
// Given an lvalue t of type remove_reference_t<T>, T models sized_range only if
// — ranges::size(t) is amortized O(1), does not modify t, and // is equal to ranges::distance( ranges::begin(t), ranges::end(t)), and
// — if iterator_t<T> models forward_iterator, ranges::size(t) is well-defined regardless of the evaluation of ranges::begin(t).
// [Note 1: ranges::size(t) is otherwise not required to be well-defined after evaluating ranges::begin(t). For example, it is possible for ranges::size(t) to be well-defined for a sized_range whose iterator type does not model forward_iterator only if evaluated before the first call to ranges::begin(t).
// — [ranges::begin(t), ranges::end(t)) denotes a range (25.3.1),
// — both ranges::begin(t) and ranges::end(t) are amortized constant time and non-modifying, and
// — if the type of ranges::begin(t) models forward_iterator, ranges::begin(t) is equality- preserving.
[//Note 1: Equality preservation of both ranges::begin and ranges::end enables passing a range whose iterator type models forward_iterator to multiple algorithms and making multiple passes over the range by repeated calls to ranges::begin and ranges::end. Since ranges::begin is not required to be equality-preserving when the return type does not model forward_iterator, it is possible for repeated calls to not return equal values or to not be well-defined. —end note]
// The sized_range concept refines range with the requirement that the number of elements in the range can be determined in amortized constant time using ranges::size.
template<class T>
concept sized_range =
template<class T>
concept borrowed_range =
range<T> && (is_lvalue_reference_v<T> || enable_borrowed_range<remove_cvref_t<T>>);
// Let U be remove_reference_t<T> if T is an rvalue reference type, and T otherwise. Given a variable u of type U, T models borrowed_range only if the validity of iterators obtained from u is not tied to the lifetime of that variable.
// [Note 2 : Since the validity of iterators is not tied to the lifetime of a variable whose type models borrowed_range, a function with a parameter of such a type can return iterators obtained from it without danger of dangling.
template<class>
inline constexpr bool enable_borrowed_range = false;
// Remarks: Pursuant to 16.4.5.2.1, users may specialize enable_borrowed_range for cv-unqualified program-defined types. Such specializations shall be usable in constant expressions (7.7) and have type const bool.
// [Example 1: Each specialization S of class template subrange (26.5.4) models borrowed_range because
// — enable_borrowed_range<S> is specialized to have the value true, and
// — S’s iterators do not have validity tied to the lifetime of an S object because they are “borrowed” from some other range.
// 26.4.3 Sized ranges [range.sized]
template<class>
inline constexpr bool disable_sized_range = false;
// Remarks: Pursuant to 16.4.5.2.1, users may specialize disable_sized_range for cv-unqualified program- defined types. Such specializations shall be usable in constant expressions (7.7) and have type const bool.
// [Note 2: disable_sized_range allows use of range types with the library that satisfy but do not in fact model sized_range.
range<T> && movable<T> && enable_view<T>;
// T models view only if:
// — T has O(1) move construction; and
// — move assignment of an object of type T is no more complex than destruction followed by move construction; and
// — if N copies and/or moves are made from an object of type T that contained M elements, then those N objects have O(N + M) destruction; and
// — copy_constructible<T> is false, or T has O(1) copy construction; and
// — copyable<T> is false, or copy assignment of an object of type T is no more complex than destruction followed by copy construction.
// [Note 1: The constraints on copying and moving imply that a moved-from object of type T has O(1) destruction. —end note]
// [Example 1: Examples of views are:
// — A range type that wraps a pair of iterators.
// — A range type that holds its elements by shared_ptr and shares ownership with all its copies. — A range type that generates its elements on demand.
// A container such as vector<string> does not meet the semantic requirements of view since copying the container copies all of the elements, which cannot be done in constant time.
// 26.4.4 Views [range.view]
// The view concept specifies the requirements of a range type that has the semantic properties below, which make it suitable for use in constructing range adaptor pipelines (26.7).
template<class T>
concept view =
// Since the difference between range and view is largely semantic, the two are differentiated with the help of enable_view.
template<class T>
inline constexpr bool is-derived-from-view-interface = see below;
template<class T>
inline constexpr bool enable_view =
// exposition only
derived_from<T, view_base> || is-derived-from-view-interface<T>;
// For a type T, is-derived-from-view-interface <T> is true if and only if T has exactly one public base class view_interface<U> for some type U and T has no base classes of type view_interface<V> for any other type V.
// Remarks: Pursuant to 16.4.5.2.1, users may specialize enable_view to true for cv-unqualified program- defined types which model view, and false for types which do not. Such specializations shall be usable in constant expressions (7.7) and have type const bool.
// The output_range concept specifies requirements of a range type for which ranges::begin returns a model of output_iterator (25.3.4.10). input_range, forward_range, bidirectional_range, and random_access_- range are defined similarly.
template<class R, class T>
concept output_range =
range<R> && output_iterator<iterator_t<R>, T>;
template<class T>
concept input_range =
range<T> && input_iterator<iterator_t<T>>;
template<class T>
concept forward_range =
input_range<T> && forward_iterator<iterator_t<T>>;
// 26.4.5 Other range refinements [range.refinements]
inline constexpr bool is-initializer-list = see below ;
// For a type R, is-initializer-list <R> is true if and only if remove_cvref_t<R> is a specialization
template<class T>
concept bidirectional_range =
forward_range<T> && bidirectional_iterator<iterator_t<T>>;
template<class T>
concept random_access_range =
bidirectional_range<T> && random_access_iterator<iterator_t<T>>;
// contiguous_range additionally requires that the ranges::data customization point object (26.3.13) is usable with the range.
template<class T>
concept contiguous_range =
random_access_range<T> && contiguous_iterator<iterator_t<T>> &&
requires(T& t) {
{
ranges::data(t)
}
-> same_as<add_pointer_t<range_reference_t<T>>>;
};
// Given an expression t such that decltype((t)) is T&, T models contiguous_range only if to_address( ranges::begin(t)) == ranges::data(t) is true.
// The common_range concept specifies requirements of a range type for which ranges::begin and ranges::end return objects of the same type.
// [Example 1: The standard containers (Clause 24) model common_range. —end example]
template<class T>
concept common_range =
range<T> && same_as<iterator_t<T>, sentinel_t<T>>;
template<class R>
// of initializer_list.
// The viewable_range concept specifies the requirements of a range type that can be converted to a view safely.
template<class T>
concept viewable_range =
range<T> &&
((view<remove_cvref_t<T>> && constructible_from<remove_cvref_t<T>, T>) ||
(!view<remove_cvref_t<T>> &&
(is_lvalue_reference_v<T> || (movable<remove_reference_t<T>> && !is-initializer-list<T>))));
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p1038.cpp -std=03 -o p1038l -I. -Wall
In file included from p1038.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 \
^
p1038.cpp:23:3: error: unknown type name 'concept'
concept range =
^
p1038.cpp:23:11: warning: variable templates are a C++14 extension [-Wc++14-extensions]
concept range =
^
p1038.cpp:24:14: error: 'T' does not refer to a value
requires(T& t) {
^
p1038.cpp:22:16: note: declared here
template<class T>
^
p1038.cpp:24:17: error: use of undeclared identifier 't'
requires(T& t) {
^
p1038.cpp:31:7: error: use of undeclared identifier 'T'
range<T> && requires(T& t) { ranges::size(t); };
^
p1038.cpp:41:6: error: expected expression
template<class T>
^
p1038.cpp:39:1: error: expected unqualified-id
[//Note 1: Equality preservation of both ranges::begin and ranges::end enables passing a range whose iterator type models forward_iterator to multiple algorithms and making multiple passes over the range by repeated calls to ranges::begin and ranges::end. Since ranges::begin is not required to be equality-preserving when the return type does not model forward_iterator, it is possible for repeated calls to not return equal values or to not be well-defined. —end note]
^
p1038.cpp:49:10: error: unknown type name 'constexpr'
inline constexpr bool enable_borrowed_range = false;
^
p1038.cpp:49:25: warning: variable templates are a C++14 extension [-Wc++14-extensions]
inline constexpr bool enable_borrowed_range = false;
^
p1038.cpp:49:3: warning: inline variables are a C++17 extension [-Wc++17-extensions]
inline constexpr bool enable_borrowed_range = false;
^
p1038.cpp:56:10: error: unknown type name 'constexpr'
inline constexpr bool disable_sized_range = false;
^
p1038.cpp:56:25: warning: variable templates are a C++14 extension [-Wc++14-extensions]
inline constexpr bool disable_sized_range = false;
^
p1038.cpp:56:3: warning: inline variables are a C++17 extension [-Wc++17-extensions]
inline constexpr bool disable_sized_range = false;
^
p1038.cpp:59:7: error: use of undeclared identifier 'T'
range<T> && movable<T> && enable_view<T>;
^
p1038.cpp:74:6: error: unknown type name 'concept'
concept view =
^
p1038.cpp:74:14: warning: variable templates are a C++14 extension [-Wc++14-extensions]
concept view =
^
p1038.cpp:76:1: error: expected expression
template<class T>
^
p1038.cpp:79:10: error: unknown type name 'constexpr'
inline constexpr bool enable_view =
^
p1038.cpp:79:25: warning: variable templates are a C++14 extension [-Wc++14-extensions]
inline constexpr bool enable_view =
^
p1038.cpp:79:3: warning: inline variables are a C++17 extension [-Wc++17-extensions]
inline constexpr bool enable_view =
^
p1038.cpp:81:17: error: use of undeclared identifier 'view_base'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:31: error: use of undeclared identifier 'is'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:34: error: use of undeclared identifier 'derived'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:42: error: use of undeclared identifier 'from'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:52: error: use of undeclared identifier 'interface'; did you mean 'internal'?
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^~~~~~~~~
internal
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/ios_base.h:1021:3: note: 'internal' declared here
internal(ios_base& __base)
^
p1038.cpp:86:6: error: unknown type name 'concept'
concept output_range =
^
p1038.cpp:86:14: warning: variable templates are a C++14 extension [-Wc++14-extensions]
concept output_range =
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
9 warnings and 20 errors generated.
$ clang++ p1038.cpp -std=2b -o p1038l -I. -Wall
p1038.cpp:31:7: error: use of undeclared identifier 'T'
range<T> && requires(T& t) { ranges::size(t); };
^
p1038.cpp:41:6: error: expected expression
template<class T>
^
p1038.cpp:39:1: error: expected unqualified-id
[//Note 1: Equality preservation of both ranges::begin and ranges::end enables passing a range whose iterator type models forward_iterator to multiple algorithms and making multiple passes over the range by repeated calls to ranges::begin and ranges::end. Since ranges::begin is not required to be equality-preserving when the return type does not model forward_iterator, it is possible for repeated calls to not return equal values or to not be well-defined. —end note]
^
p1038.cpp:59:7: error: use of undeclared identifier 'T'
range<T> && movable<T> && enable_view<T>;
^
p1038.cpp:76:1: error: expected expression
template<class T>
^
p1038.cpp:81:17: error: unknown type name 'view_base'; did you mean 'std::ranges::view_base'?
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^~~~~~~~~
std::ranges::view_base
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/ranges:66:10: note: 'std::ranges::view_base' declared here
struct view_base { };
^
p1038.cpp:81:31: error: use of undeclared identifier 'is'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:34: error: use of undeclared identifier 'derived'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:42: error: use of undeclared identifier 'from'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:47: error: use of undeclared identifier 'view'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:81:52: error: use of undeclared identifier 'interface'
derived_from<T, view_base> || is-derived-from-view-interface<T>;
^
p1038.cpp:87:36: error: use of undeclared identifier 'iterator_t'
range<R> && output_iterator<iterator_t<R>, T>;
^
p1038.cpp:90:35: error: use of undeclared identifier 'iterator_t'
range<T> && input_iterator<iterator_t<T>>;
^
p1038.cpp:93:43: error: use of undeclared identifier 'iterator_t'
input_range<T> && forward_iterator<iterator_t<T>>;
^
p1038.cpp:93:8: error: use of undeclared identifier 'input_range'
input_range<T> && forward_iterator<iterator_t<T>>;
^
p1038.cpp:95:23: error: default initialization of an object of const type 'const bool'
inline constexpr bool is-initializer-list = see below ;
^
= false
p1038.cpp:95:25: error: expected ';' after top level declarator
inline constexpr bool is-initializer-list = see below ;
^
;
p1038.cpp:99:51: error: use of undeclared identifier 'iterator_t'
forward_range<T> && bidirectional_iterator<iterator_t<T>>;
^
p1038.cpp:99:8: error: use of undeclared identifier 'forward_range'
forward_range<T> && bidirectional_iterator<iterator_t<T>>;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p1038.cpp -std=03 -o p1038g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from N4910.h:11,
from p1038.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 \
| ^~~~~
p1038.cpp:49:10: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
49 | inline constexpr bool enable_borrowed_range = false;
| ^~~~~~~~~
p1038.cpp:23:3: error: 'concept' does not name a type; did you mean 'const'?
23 | concept range =
| ^~~~~~~
| const
p1038.cpp:23:3: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:31:1: error: 'range' does not name a type
31 | range<T> && requires(T& t) { ranges::size(t); };
| ^~~~~
p1038.cpp:39:1: error: expected unqualified-id before '[' token
39 | [//Note 1: Equality preservation of both ranges::begin and ranges::end enables passing a range whose iterator type models forward_iterator to multiple algorithms and making multiple passes over the range by repeated calls to ranges::begin and ranges::end. Since ranges::begin is not required to be equality-preserving when the return type does not model forward_iterator, it is possible for repeated calls to not return equal values or to not be well-defined. —end note]
| ^
p1038.cpp:49:10: error: 'constexpr' does not name a type
49 | inline constexpr bool enable_borrowed_range = false;
| ^~~~~~~~~
p1038.cpp:49:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1038.cpp:56:10: error: 'constexpr' does not name a type
56 | inline constexpr bool disable_sized_range = false;
| ^~~~~~~~~
p1038.cpp:56:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1038.cpp:59:1: error: 'range' does not name a type
59 | range<T> && movable<T> && enable_view<T>;
| ^~~~~
p1038.cpp:74:6: error: 'concept' does not name a type; did you mean 'const'?
74 | concept view =
| ^~~~~~~
| const
p1038.cpp:74:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:79:10: error: 'constexpr' does not name a type
79 | inline constexpr bool enable_view =
| ^~~~~~~~~
p1038.cpp:79:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1038.cpp:86:6: error: 'concept' does not name a type; did you mean 'const'?
86 | concept output_range =
| ^~~~~~~
| const
p1038.cpp:86:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:89:6: error: 'concept' does not name a type; did you mean 'const'?
89 | concept input_range =
| ^~~~~~~
| const
p1038.cpp:89:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:92:6: error: 'concept' does not name a type; did you mean 'const'?
92 | concept forward_range =
| ^~~~~~~
| const
p1038.cpp:92:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:95:8: error: 'constexpr' does not name a type
95 | inline constexpr bool is-initializer-list = see below ;
| ^~~~~~~~~
p1038.cpp:95:8: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1038.cpp:98:6: error: 'concept' does not name a type; did you mean 'const'?
98 | concept bidirectional_range =
| ^~~~~~~
| const
p1038.cpp:98:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:101:6: error: 'concept' does not name a type; did you mean 'const'?
101 | concept random_access_range =
| ^~~~~~~
| const
p1038.cpp:101:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:105:6: error: 'concept' does not name a type; did you mean 'const'?
105 | concept contiguous_range =
| ^~~~~~~
| const
p1038.cpp:105:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:114:6: error: 'concept' does not name a type; did you mean 'const'?
114 | concept common_range =
| ^~~~~~~
| const
p1038.cpp:114:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
p1038.cpp:120:6: error: 'concept' does not name a type; did you mean 'const'?
120 | concept viewable_range =
| ^~~~~~~
| const
p1038.cpp:120:6: note: 'concept' only available with '-std=c++20' or '-fconcepts'
$ g++ p1038.cpp -std=2b -o p1038g -I. -Wall
p1038.cpp:31:7: error: 'T' was not declared in this scope
31 | range<T> && requires(T& t) { ranges::size(t); };
| ^
p1038.cpp:31:1: error: template argument 1 is invalid
31 | range<T> && requires(T& t) { ranges::size(t); };
| ^~~~~~~~
p1038.cpp:31:1: error: '<expression error>' does not name a type
p1038.cpp:39:1: error: expected unqualified-id before '[' token
39 | [//Note 1: Equality preservation of both ranges::begin and ranges::end enables passing a range whose iterator type models forward_iterator to multiple algorithms and making multiple passes over the range by repeated calls to ranges::begin and ranges::end. Since ranges::begin is not required to be equality-preserving when the return type does not model forward_iterator, it is possible for repeated calls to not return equal values or to not be well-defined. —end note]
| ^
p1038.cpp:59:7: error: 'T' was not declared in this scope
59 | range<T> && movable<T> && enable_view<T>;
| ^
p1038.cpp:59:1: error: template argument 1 is invalid
59 | range<T> && movable<T> && enable_view<T>;
| ^~~~~~~~
p1038.cpp:59:1: error: '<expression error>' does not name a type
p1038.cpp:76:1: error: expected primary-expression before 'template'
76 | template<class T>
| ^~~~~~~~
p1038.cpp:81:17: error: 'view_base' was not declared in this scope; did you mean 'std::ranges::view_base'?
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~~~~~~~~
| std::ranges::view_base
In file included from /usr/local/include/c++/12.1.0/string_view:50,
from /usr/local/include/c++/12.1.0/bits/basic_string.h:48,
from /usr/local/include/c++/12.1.0/string:53,
from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
from /usr/local/include/c++/12.1.0/ios:42,
from /usr/local/include/c++/12.1.0/ostream:38,
from /usr/local/include/c++/12.1.0/iostream:39,
from N4910.h:2,
from p1038.cpp:10:
/usr/local/include/c++/12.1.0/bits/ranges_base.h:640:10: note: 'std::ranges::view_base' declared here
640 | struct view_base { };
| ^~~~~~~~~
p1038.cpp:81:1: error: template argument 2 is invalid
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:81:31: error: 'is' was not declared in this scope
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~
p1038.cpp:81:34: error: 'derived' was not declared in this scope
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~~~~~~
p1038.cpp:81:42: error: 'from' was not declared in this scope; did you mean 'fromfp'?
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~~~
| fromfp
p1038.cpp:81:47: error: expected 'auto' or 'decltype(auto)' after 'view'
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~~~
p1038.cpp:81:51: error: missing template arguments before '-' token
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^
p1038.cpp:81:52: error: 'interface' was not declared in this scope
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^~~~~~~~~
p1038.cpp:81:63: error: expected primary-expression before '>' token
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^
p1038.cpp:81:64: error: expected primary-expression before ';' token
81 | derived_from<T, view_base> || is-derived-from-view-interface<T>;
| ^
p1038.cpp:87:36: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
87 | range<R> && output_iterator<iterator_t<R>, T>;
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:87:20: error: parse error in template argument list
87 | range<R> && output_iterator<iterator_t<R>, T>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:87:20: error: wrong number of template arguments (1, should be 2)
In file included from /usr/local/include/c++/12.1.0/bits/stl_iterator_base_types.h:71,
from /usr/local/include/c++/12.1.0/bits/stl_construct.h:61,
from /usr/local/include/c++/12.1.0/bits/char_traits.h:46,
from /usr/local/include/c++/12.1.0/ios:40:
/usr/local/include/c++/12.1.0/bits/iterator_concepts.h:642:13: note: provided for 'template<class _Iter, class _Tp> concept std::output_iterator'
642 | concept output_iterator = input_or_output_iterator<_Iter>
| ^~~~~~~~~~~~~~~
p1038.cpp:90:35: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
90 | range<T> && input_iterator<iterator_t<T>>;
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:90:20: error: parse error in template argument list
90 | range<T> && input_iterator<iterator_t<T>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:90:20: error: template argument 1 is invalid
p1038.cpp:93:43: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
93 | input_range<T> && forward_iterator<iterator_t<T>>;
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:93:26: error: parse error in template argument list
93 | input_range<T> && forward_iterator<iterator_t<T>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:93:26: error: template argument 1 is invalid
p1038.cpp:95:25: error: expected initializer before '-' token
95 | inline constexpr bool is-initializer-list = see below ;
| ^
p1038.cpp:99:51: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
99 | forward_range<T> && bidirectional_iterator<iterator_t<T>>;
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:99:28: error: parse error in template argument list
99 | forward_range<T> && bidirectional_iterator<iterator_t<T>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:99:28: error: template argument 1 is invalid
p1038.cpp:102:57: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
102 | bidirectional_range<T> && random_access_iterator<iterator_t<T>>;
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:102:34: error: parse error in template argument list
102 | bidirectional_range<T> && random_access_iterator<iterator_t<T>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:102:34: error: template argument 1 is invalid
p1038.cpp:106:54: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
106 | random_access_range<T> && contiguous_iterator<iterator_t<T>> &&
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:106:34: error: parse error in template argument list
106 | random_access_range<T> && contiguous_iterator<iterator_t<T>> &&
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:106:34: error: template argument 1 is invalid
p1038.cpp:108:55: error: 'range_reference_t' was not declared in this scope; did you mean 'std::ranges::range_reference_t'?
108 | { ranges::data(t) } -> same_as<add_pointer_t<range_reference_t<T>>>;
| ^~~~~~~~~~~~~~~~~
| std::ranges::range_reference_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:607:11: note: 'std::ranges::range_reference_t' declared here
607 | using range_reference_t = iter_reference_t<iterator_t<_Range>>;
| ^~~~~~~~~~~~~~~~~
p1038.cpp:108:74: error: template argument 1 is invalid
108 | { ranges::data(t) } -> same_as<add_pointer_t<range_reference_t<T>>>;
| ^~
p1038.cpp:108:33: error: wrong number of template arguments (1, should be 2)
108 | { ranges::data(t) } -> same_as<add_pointer_t<range_reference_t<T>>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/c++/12.1.0/compare:39,
from /usr/local/include/c++/12.1.0/bits/char_traits.h:45:
/usr/local/include/c++/12.1.0/concepts:62:13: note: provided for 'template<class _Tp, class _Up> concept std::same_as'
62 | concept same_as
| ^~~~~~~
p1038.cpp:108:33: error: '<expression error>' does not name a type
108 | { ranges::data(t) } -> same_as<add_pointer_t<range_reference_t<T>>>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p1038.cpp:108:77: error: expected primary-expression before ';' token
108 | { ranges::data(t) } -> same_as<add_pointer_t<range_reference_t<T>>>;
| ^
p1038.cpp:115:28: error: 'iterator_t' was not declared in this scope; did you mean 'std::ranges::iterator_t'?
115 | range<T> && same_as<iterator_t<T>, sentinel_t<T>>;
| ^~~~~~~~~~
| std::ranges::iterator_t
/usr/local/include/c++/12.1.0/bits/ranges_base.h:595:11: note: 'std::ranges::iterator_t' declared here
595 | using iterator_t = std::__detail::__range_iter_t<_Tp>;
| ^~~~~~~~~~
p1038.cpp:115:20: error: parse error in template argument list
115 | range<T> && same_as<iterator_t<T>, sentinel_t<T>>;
| ^~~~~~~~~~~~~~~~~~~~~
p1038.cpp:115:20: error: wrong number of template arguments (1, should be 2)
/usr/local/include/c++/12.1.0/concepts:62:13: note: provided for 'template<class _Tp, class _Up> concept std::same_as'
62 | concept same_as
| ^~~~~~~
p1038.cpp:124:66: error: 'is' was not declared in this scope
124 | (is_lvalue_reference_v<T> || (movable<remove_reference_t<T>> && !is-initializer-list<T>))));
| ^~
p1038.cpp:124:69: error: 'initializer' was not declared in this scope
124 | (is_lvalue_reference_v<T> || (movable<remove_reference_t<T>> && !is-initializer-list<T>))));
| ^~~~~~~~~~~
p1038.cpp:124:81: error: 'list' was not declared in this scope
124 | (is_lvalue_reference_v<T> || (movable<remove_reference_t<T>> && !is-initializer-list<T>))));
| ^~~~
p1038.cpp:11:1: note: 'std::list' is defined in header '<list>'; did you forget to '#include <list>'?
10 | #include "N4910.h"
+++ |+#include <list>
11 |
p1038.cpp:124:87: error: expected primary-expression before '>' token
124 | (is_lvalue_reference_v<T> || (movable<remove_reference_t<T>> && !is-initializer-list<T>))));
| ^
p1038.cpp:124:88: error: expected primary-expression before ')' token
124 | (is_lvalue_reference_v<T> || (movable<remove_reference_t<T>> && !is-initializer-list<T>))));
| ^
p1038.cpp:120:14: error: concept 'viewable_range' has multiple template parameter lists
120 | concept viewable_range =
| ^~~~~~~~~~~~~~
検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。
参考資料(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 使ってみた
DoCAP(ドゥーキャップ)って何ですか?
小川メソッド 覚え(書きかけ)
<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
文書履歴(document history)
ver. 0.01 初稿 20220811