はじめに(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.
22.15 Bit manipulation [bit] C++N4910:2022 (633) p788.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 = "22.15 Bit manipulation [bit] C++N4910:2022 (633) p788.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;
const int see_below =1;
// 22.15.1 General [bit.general]
// The header <bit> provides components to access, manipulate and process both individual bits and bit sequences.
// Returns: An object of type To. Implicitly creates objects nested within the result (6.7.2). Each bit of the value representation of the result is equal to the corresponding bit in the object representation of from. Padding bits of the result are unspecified. For the result and each object created within it, if there is no value of the object’s type corresponding to the value representation produced, the behavior is undefined. If there are multiple such values, which value is produced is unspecified. A bit in the value representation of the result is indeterminate if it does not correspond to a bit in the value representation of from or corresponds to a bit of an object that is not within its lifetime or has an
// 22.15.2 Header <bit> synopsis [bit.syn]
namespace std {
// 22.15.3, bit_cast template<class To, class From>
constexpr To bit_cast(const From& from) noexcept;
// 22.15.4, byteswap template<class T>
constexpr T byteswap(T value) noexcept;
// 22.15.5, integral powers of 2 template<class T>
constexpr bool has_single_bit(T x) noexcept;
template<class T>
constexpr T bit_ceil(T x);
template<class T>
constexpr T bit_floor(T x) noexcept;
template<class T>
constexpr T bit_width(T x) noexcept;
// 22.15.6, rotating template<class T>
[[nodiscard]] constexpr T rotl(T x, int s) noexcept;
template<class T>
[[nodiscard]] constexpr T rotr(T x, int s) noexcept;
// 22.15.7, counting template<class T>
constexpr int countl_zero(T x) noexcept;
template<class T>
constexpr int countl_one(T x) noexcept;
template<class T>
constexpr int countr_zero(T x) noexcept;
template<class T>
constexpr int countr_one(T x) noexcept;
template<class T>
constexpr int popcount(T x) noexcept;
// 22.15.8, endian enum class endian {
little = see_below, big = see_below, native = see_below
};
}
// 22.15.3 Function template bit_cast [bit.cast]
template<class To, class From>
constexpr To bit_cast(const From& from) noexcept;
// Constraints: — sizeof(To) == sizeof(From) is true;
// — is_trivially_copyable_v<To> is true; and
// — is_trivially_copyable_v<From> is true.
// indeterminate value (6.7.4). For each bit in the value representation of the result that is indeterminate, the smallest object containing that bit has an indeterminate value; the behavior is undefined unless that object is of unsigned ordinary character type or std::byte type. The result does not otherwise contain any indeterminate values.
// Remarks: This function is constexpr if and only if To, From, and the types of all subobjects of To and From are types T such that:
// In the following descriptions, let N denote numeric_limits<T>::digits.
// — is_union_v<T> is false;
// — is_pointer_v<T> is false;
// — is_member_pointer_v<T> is false;
// — is_volatile_v<T> is false; and
// — T has no non-static data members of reference type.
// 22.15.4 byteswap [bit.byteswap]
template<class T>
constexpr T byteswap(T value) noexcept;
// Constraints: T models integral.
// Mandates: T does not have padding bits (6.8.1).
// Let the sequence R comprise the bytes of the object representation of value in reverse order.
// Returns: An object v of type T such that each byte in the object representation of v is equal to the byte in the corresponding position in R.
// 22.15.5 Integral powers of 2 [bit.pow.two]
template<class T>
constexpr bool has_single_bit(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: true if x is an integral power of two; false otherwise.
template<class T>
constexpr T bit_ceil(T x);
// Let N be the smallest power of 2 greater than or equal to x. Constraints: T is an unsigned integer type (6.8.2). Preconditions: N is representable as a value of type T. Returns: N.
// Throws: Nothing.
// Remarks: A function call expression that violates the precondition in the Preconditions: element is not a core constant expression (7.7).
template<class T>
constexpr T bit_floor(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: If x == 0, 0; otherwise the maximal value y such that has_single_bit(y) is true and y <= x.
template<class T>
constexpr T bit_width(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: If x == 0, 0; otherwise one plus the base-2 logarithm of x, with any fractional part discarded.
// 22.15.6 Rotating [bit.rotate]
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: The number of consecutive 0 bits in the value of x, starting from the most significant bit. [Note 1: Returns N if x == 0. —end note]
template<class T>
[[nodiscard]] constexpr T rotl(T x, int s) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Letrbes % N.
// Returns: If r is 0, x; if r is positive, (x << r) | (x >> (N - r)); if r is negative, rotr(x, -r).
// In the following descriptions, let N denote numeric_limits<T>::digits. template<class T>
template<class T>
[[nodiscard]] constexpr T rotr(T x, int s) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Letrbes % N.
// Returns: If r is 0, x; if r is positive, (x >> r) | (x << (N - r)); if r is negative, rotl(x, -r).
// 22.15.7 Counting [bit.count]
constexpr int countl_zero(T x) noexcept;
template<class T>
constexpr int countl_one(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: The number of consecutive 1 bits in the value of x, starting from the most significant bit.
// [Note 2: Returns N if x == numeric_limits<T>::max().
template<class T>
constexpr int countr_zero(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: The number of consecutive 0 bits in the value of x, starting from the least significant bit. [Note 3: Returns N if x == 0. —end note]
template<class T>
constexpr int countr_one(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2).
// Returns: The number of consecutive 1 bits in the value of x, starting from the least significant bit.
// [Note 4: Returns N if x == numeric_limits<T>::max().
template<class T>
constexpr int popcount(T x) noexcept;
// Constraints: T is an unsigned integer type (6.8.2). Returns: The number of 1 bits in the value of x.
// 22.15.8 Endian [bit.endian]
// Two common methods of byte ordering in multibyte scalar types are big-endian and little-endian in the execution environment. Big-endian is a format for storage of binary data in which the most significant byte is placed first, with the rest in descending order. Little-endian is a format for storage of binary data in which the least significant byte is placed first, with the rest in ascending order. This subclause describes the endianness of the scalar types of the execution environment.
enum class endian { little = see_below, big = see_below, native = see_below
};
// If all scalar types have size 1 byte, then all of endian::little, endian::big, and endian::native have the same value. Otherwise, endian::little is not equal to endian::big. If all scalar types are big- endian, endian::native is equal to endian::big. If all scalar types are little-endian, endian::native is equal to endian::little. Otherwise, endian::native is not equal to either endian::big or endian::little.
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p788.cpp -std=03 -o p788l -I. -Wall
In file included from p788.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 \
^
p788.cpp:21:7: error: unknown type name 'constexpr'
constexpr To bit_cast(const From& from) noexcept;
^
p788.cpp:21:19: error: expected ';' after top level declarator
constexpr To bit_cast(const From& from) noexcept;
^
;
p788.cpp:23:7: error: unknown type name 'constexpr'
constexpr T byteswap(T value) noexcept;
^
p788.cpp:23:18: error: expected ';' after top level declarator
constexpr T byteswap(T value) noexcept;
^
;
p788.cpp:25:7: error: unknown type name 'constexpr'
constexpr bool has_single_bit(T x) noexcept;
^
p788.cpp:25:37: error: unknown type name 'T'
constexpr bool has_single_bit(T x) noexcept;
^
p788.cpp:25:42: error: expected function body after function declarator
constexpr bool has_single_bit(T x) noexcept;
^
p788.cpp:27:7: error: unknown type name 'constexpr'
constexpr T bit_ceil(T x);
^
p788.cpp:27:17: warning: variable templates are a C++14 extension [-Wc++14-extensions]
constexpr T bit_ceil(T x);
^
p788.cpp:27:18: error: expected ';' at end of declaration
constexpr T bit_ceil(T x);
^
;
p788.cpp:27:28: error: unknown type name 'T'
constexpr T bit_ceil(T x);
^
p788.cpp:27:19: error: C++ requires a type specifier for all declarations
constexpr T bit_ceil(T x);
^
p788.cpp:29:7: error: unknown type name 'constexpr'
constexpr T bit_floor(T x) noexcept;
^
p788.cpp:29:17: warning: variable templates are a C++14 extension [-Wc++14-extensions]
constexpr T bit_floor(T x) noexcept;
^
p788.cpp:29:18: error: expected ';' at end of declaration
constexpr T bit_floor(T x) noexcept;
^
;
p788.cpp:29:29: error: unknown type name 'T'
constexpr T bit_floor(T x) noexcept;
^
p788.cpp:29:34: error: expected function body after function declarator
constexpr T bit_floor(T x) noexcept;
^
p788.cpp:31:7: error: unknown type name 'constexpr'
constexpr T bit_width(T x) noexcept;
^
p788.cpp:31:17: warning: variable templates are a C++14 extension [-Wc++14-extensions]
constexpr T bit_width(T x) noexcept;
^
p788.cpp:31:18: error: expected ';' at end of declaration
constexpr T bit_width(T x) noexcept;
^
;
p788.cpp:31:29: error: unknown type name 'T'
constexpr T bit_width(T x) noexcept;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
3 warnings and 20 errors generated.
$ clang++ p788.cpp -std=2b -o p788l -I. -Wall
p788.cpp:21:17: error: unknown type name 'To'
constexpr To bit_cast(const From& from) noexcept;
^
p788.cpp:21:35: error: unknown type name 'From'
constexpr To bit_cast(const From& from) noexcept;
^
p788.cpp:23:17: error: unknown type name 'T'
constexpr T byteswap(T value) noexcept;
^
p788.cpp:23:28: error: unknown type name 'T'
constexpr T byteswap(T value) noexcept;
^
p788.cpp:25:37: error: unknown type name 'T'
constexpr bool has_single_bit(T x) noexcept;
^
p788.cpp:33:31: error: unknown type name 'T'
[[nodiscard]] constexpr T rotl(T x, int s) noexcept;
^
p788.cpp:33:38: error: unknown type name 'T'
[[nodiscard]] constexpr T rotl(T x, int s) noexcept;
^
p788.cpp:37:33: error: unknown type name 'T'
constexpr int countl_zero(T x) noexcept;
^
p788.cpp:47:1: error: C++ requires a type specifier for all declarations
little = see_below, big = see_below, native = see_below
^
p788.cpp:47:24: error: expected ';' after top level declarator
little = see_below, big = see_below, native = see_below
^
;
p788.cpp:48:4: error: extraneous closing brace ('}')
}; }
^
p788.cpp:103:27: error: unknown type name 'T'
constexpr int countl_zero(T x) noexcept;
^
12 errors generated.
$ g++ p788.cpp -std=03 -o p788g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from N4910.h:11,
from p788.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 \
| ^~~~~
p788.cpp:21:7: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
21 | constexpr To bit_cast(const From& from) noexcept;
| ^~~~~~~~~
p788.cpp:21:47: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
21 | constexpr To bit_cast(const From& from) noexcept;
| ^~~~~~~~
p788.cpp:21:7: error: 'constexpr' does not name a type
21 | constexpr To bit_cast(const From& from) noexcept;
| ^~~~~~~~~
p788.cpp:21:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:23:7: error: 'constexpr' does not name a type
23 | constexpr T byteswap(T value) noexcept;
| ^~~~~~~~~
p788.cpp:23:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:25:7: error: 'constexpr' does not name a type
25 | constexpr bool has_single_bit(T x) noexcept;
| ^~~~~~~~~
p788.cpp:25:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:27:7: error: 'constexpr' does not name a type
27 | constexpr T bit_ceil(T x);
| ^~~~~~~~~
p788.cpp:27:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:29:7: error: 'constexpr' does not name a type
29 | constexpr T bit_floor(T x) noexcept;
| ^~~~~~~~~
p788.cpp:29:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:31:7: error: 'constexpr' does not name a type
31 | constexpr T bit_width(T x) noexcept;
| ^~~~~~~~~
p788.cpp:31:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:33:7: error: expected unqualified-id before '[' token
33 | [[nodiscard]] constexpr T rotl(T x, int s) noexcept;
| ^
p788.cpp:35:7: error: expected unqualified-id before '[' token
35 | [[nodiscard]] constexpr T rotr(T x, int s) noexcept;
| ^
p788.cpp:37:7: error: 'constexpr' does not name a type
37 | constexpr int countl_zero(T x) noexcept;
| ^~~~~~~~~
p788.cpp:37:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:39:7: error: 'constexpr' does not name a type
39 | constexpr int countl_one(T x) noexcept;
| ^~~~~~~~~
p788.cpp:39:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:41:7: error: 'constexpr' does not name a type
41 | constexpr int countr_zero(T x) noexcept;
| ^~~~~~~~~
p788.cpp:41:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:43:7: error: 'constexpr' does not name a type
43 | constexpr int countr_one(T x) noexcept;
| ^~~~~~~~~
p788.cpp:43:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:45:7: error: 'constexpr' does not name a type
45 | constexpr int popcount(T x) noexcept;
| ^~~~~~~~~
p788.cpp:45:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:47:1: error: 'little' does not name a type
47 | little = see_below, big = see_below, native = see_below
| ^~~~~~
p788.cpp:48:4: error: expected declaration before '}' token
48 | }; }
| ^
p788.cpp:51:3: error: 'constexpr' does not name a type
51 | constexpr To bit_cast(const From& from) noexcept;
| ^~~~~~~~~
p788.cpp:51:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:65:1: error: 'constexpr' does not name a type
65 | constexpr T byteswap(T value) noexcept;
| ^~~~~~~~~
p788.cpp:65:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:72:3: error: 'constexpr' does not name a type
72 | constexpr bool has_single_bit(T x) noexcept;
| ^~~~~~~~~
p788.cpp:72:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:76:3: error: 'constexpr' does not name a type
76 | constexpr T bit_ceil(T x);
| ^~~~~~~~~
p788.cpp:76:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:81:1: error: 'constexpr' does not name a type
81 | constexpr T bit_floor(T x) noexcept;
| ^~~~~~~~~
p788.cpp:81:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:85:1: error: 'constexpr' does not name a type
85 | constexpr T bit_width(T x) noexcept;
| ^~~~~~~~~
p788.cpp:85:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:92:3: error: expected unqualified-id before '[' token
92 | [[nodiscard]] constexpr T rotl(T x, int s) noexcept;
| ^
p788.cpp:98:3: error: expected unqualified-id before '[' token
98 | [[nodiscard]] constexpr T rotr(T x, int s) noexcept;
| ^
p788.cpp:103:1: error: 'constexpr' does not name a type
103 | constexpr int countl_zero(T x) noexcept;
| ^~~~~~~~~
p788.cpp:103:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:105:3: error: 'constexpr' does not name a type
105 | constexpr int countl_one(T x) noexcept;
| ^~~~~~~~~
p788.cpp:105:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:110:3: error: 'constexpr' does not name a type
110 | constexpr int countr_zero(T x) noexcept;
| ^~~~~~~~~
p788.cpp:110:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:114:3: error: 'constexpr' does not name a type
114 | constexpr int countr_one(T x) noexcept;
| ^~~~~~~~~
p788.cpp:114:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:119:3: error: 'constexpr' does not name a type
119 | constexpr int popcount(T x) noexcept;
| ^~~~~~~~~
p788.cpp:119:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p788.cpp:123:1: warning: scoped enums only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
123 | enum class endian { little = see_below, big = see_below, native = see_below
| ^~~~
$ g++ p788.cpp -std=2b -o p788g -I. -Wall
p788.cpp:21:17: error: 'To' does not name a type
21 | constexpr To bit_cast(const From& from) noexcept;
| ^~
p788.cpp:23:17: error: 'T' does not name a type
23 | constexpr T byteswap(T value) noexcept;
| ^
p788.cpp:25:37: error: 'constexpr const bool std::has_single_bit' redeclared as different kind of entity
25 | constexpr bool has_single_bit(T x) noexcept;
| ^
In file included from /usr/local/include/c++/12.1.0/bits/align.h:35,
from /usr/local/include/c++/12.1.0/memory:72,
from N4910.h:14,
from p788.cpp:10:
/usr/local/include/c++/12.1.0/bit:436:5: note: previous declaration 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, bool> std::has_single_bit(_Tp)'
436 | has_single_bit(_Tp __x) noexcept
| ^~~~~~~~~~~~~~
p788.cpp:25:37: error: 'T' was not declared in this scope
25 | constexpr bool has_single_bit(T x) noexcept;
| ^
p788.cpp:33:31: error: 'T' does not name a type
33 | [[nodiscard]] constexpr T rotl(T x, int s) noexcept;
| ^
p788.cpp:37:33: error: 'constexpr const int std::countl_zero' redeclared as different kind of entity
37 | constexpr int countl_zero(T x) noexcept;
| ^
/usr/local/include/c++/12.1.0/bit:402:5: note: previous declaration 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, int> std::countl_zero(_Tp)'
402 | countl_zero(_Tp __x) noexcept
| ^~~~~~~~~~~
p788.cpp:37:33: error: 'T' was not declared in this scope
37 | constexpr int countl_zero(T x) noexcept;
| ^
p788.cpp:47:1: error: 'little' does not name a type
47 | little = see_below, big = see_below, native = see_below
| ^~~~~~
p788.cpp:48:4: error: expected declaration before '}' token
48 | }; }
| ^
p788.cpp:103:27: error: 'T' was not declared in this scope
103 | constexpr int countl_zero(T x) noexcept;
| ^
検討事項(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 初稿 20220801