はじめに(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.10.2 Header synopsis [functional.syn] C++N4910:2022 (613) p738.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.10.2 Header <functional> synopsis [functional.syn] C++N4910:2022 (613) p738.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. OGAWA Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91
#include "N4910.h"
using namespace std;
//
namespace std {
// 22.10.5, invoke
template<class F, class... Args>
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
noexcept(is_nothrow_invocable_v<F, Args...>);
template<class R, class F, class... Args>
constexpr R invoke_r(F&& f, Args&&... args)
noexcept(is_nothrow_invocable_r_v<R, F, Args...>);
// 22.10.6, reference_wrapper
template<class T> class reference_wrapper;
template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
template<class T> constexpr reference_wrapper<const T> cref(const T&) noexcept;
template<class T> void ref(const T&&) = delete;
template<class T> void cref(const T&&) = delete;
template<class T> constexpr reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
template<class T> constexpr reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
// 22.10.7, arithmetic operations
template<class T = void> struct plus;
template<class T = void> struct minus;
template<class T = void> struct multiplies;
template<class T = void> struct divides;
template<class T = void> struct modulus;
template<class T = void> struct negate;
template<> struct plus<void>;
template<> struct minus<void>;
template<> struct multiplies<void>;
template<> struct divides<void>;
template<> struct modulus<void>;
template<> struct negate<void>;
// 22.10.8, comparisons
template<class T = void> struct equal_to;
template<class T = void> struct not_equal_to;
template<class T = void> struct greater;
template<class T = void> struct less;
template<class T = void> struct greater_equal;
template<class T = void> struct less_equal;
template<> struct equal_to<void>;
template<> struct not_equal_to<void>;
template<> struct greater<void>;
template<> struct less<void>;
template<> struct greater_equal<void>;
template<> struct less_equal<void>;
// 22.10.8.8, class compare_three_way struct compare_three_way;
// 22.10.10, logical operations
template<class T = void> struct logical_and;
template<class T = void> struct logical_or;
template<class T = void> struct logical_not;
template<> struct logical_and<void>;
template<> struct logical_or<void>;
template<> struct logical_not<void>;
// 22.10.11, bitwise operations template<class T = void> struct bit_and; template<class T = void> struct bit_or; template<class T = void> struct bit_xor; template<class T = void> struct bit_not; template<> struct bit_and<void>; template<> struct bit_or<void>; template<> struct bit_xor<void>; template<> struct bit_not<void>;
// 22.10.12, identity struct identity;
// 22.10.13, function template not_fn
template<class F> constexpr unspecified not_fn(F&& f);
// 22.10.14, function templates bind_front and bind_back
template<class F, class... Args> constexpr unspecified bind_front(F&&, Args&&...);
template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
// 22.10.15, bind
template<class T> struct is_bind_expression;
template<class T>
inline constexpr bool is_bind_expression_v = is_bind_expression<T>::value;
template<class T> struct is_placeholder;
template<class T>
inline constexpr int is_placeholder_v = is_placeholder<T>::value;
template<class F, class... BoundArgs>
constexpr unspecified bind(F&&, BoundArgs&&...);
template<class R, class F, class... BoundArgs> constexpr unspecified bind(F&&, BoundArgs&&...);
namespace placeholders {
// M is the implementation-defined number of placeholders see below _1;
see below _2;
. . .
see below _M;
}
// 22.10.16, member function adaptors template<class R, class T>
constexpr unspecified mem_fn(R T::*) noexcept; // 22.10.17, polymorphic function wrappers
class bad_function_call;
template<class> class function; // not defined
template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
// 22.10.17.3.8, specialized algorithms template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
// 22.10.17.3.7, null pointer comparison operator functions template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
// 22.10.17.4, move only wrapper
template<class... S> class move_only_function; // not defined template<class R, class... ArgTypes>
class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
// 22.10.18, searchers
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
class default_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher;
// 22.10.19, class template hash template<class T>
struct hash;
namespace ranges {
// 22.10.9, concept-constrained comparisons struct equal_to;
struct not_equal_to;
struct greater;
struct less;
struct greater_equal;
struct less_equal;
}
}
// [Example 1: If a C++ program wants to have a by-element addition of two vectors a and b containing double and put the result into a, it can do:
transform(a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
// [Example 2: To negate every element of a:
transform(a.begin(), a.end(), a.begin(), negate<double>());
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p738.cpp -std=03 -o p738l -I. -Wall
In file included from p738.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 \
^
p738.cpp:17:24: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template<class F, class... Args>
^
p738.cpp:18:7: error: unknown type name 'constexpr'
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
p738.cpp:18:17: error: no variable template matches partial specialization
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
p738.cpp:18:44: error: expected ';' at end of declaration
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
;
p738.cpp:18:52: error: unknown type name 'F'
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
p738.cpp:18:53: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
p738.cpp:18:59: error: unknown type name 'Args'
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
p738.cpp:18:63: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
^
p738.cpp:18:65: error: type 'int &&' of function parameter pack does not contain any unexpanded parameter packs
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
~~~~~~^~~~~~~~
p738.cpp:19:9: error: expected function body after function declarator
noexcept(is_nothrow_invocable_v<F, Args...>);
^
p738.cpp:20:37: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template<class R, class F, class... Args>
^
p738.cpp:21:7: error: unknown type name 'constexpr'
constexpr R invoke_r(F&& f, Args&&... args)
^
p738.cpp:21:17: warning: variable templates are a C++14 extension [-Wc++14-extensions]
constexpr R invoke_r(F&& f, Args&&... args)
^
p738.cpp:21:18: error: expected ';' at end of declaration
constexpr R invoke_r(F&& f, Args&&... args)
^
;
p738.cpp:21:28: error: unknown type name 'F'
constexpr R invoke_r(F&& f, Args&&... args)
^
p738.cpp:21:29: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr R invoke_r(F&& f, Args&&... args)
^
p738.cpp:21:35: error: unknown type name 'Args'
constexpr R invoke_r(F&& f, Args&&... args)
^
p738.cpp:21:39: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
constexpr R invoke_r(F&& f, Args&&... args)
^
p738.cpp:21:41: error: type 'int &&' of function parameter pack does not contain any unexpanded parameter packs
constexpr R invoke_r(F&& f, Args&&... args)
~~~~~~^~~~~~~~
p738.cpp:22:9: error: expected function body after function declarator
noexcept(is_nothrow_invocable_r_v<R, F, Args...>);
^
p738.cpp:25:23: error: unknown type name 'constexpr'
template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
^
p738.cpp:25:33: error: no variable template matches partial specialization
template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
^
p738.cpp:25:53: error: expected ';' at end of declaration
template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
^
;
p738.cpp:25:58: error: unknown type name 'T'
template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
^
p738.cpp:25:62: error: expected function body after function declarator
template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
7 warnings and 20 errors generated.
$ clang++ p738.cpp -std=2b -o p738l -I. -Wall
p738.cpp:27:28: error: redefinition of 'ref'
template<class T> void ref(const T&&) = delete;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/refwrap.h:375:10: note: previous definition is here
void ref(const _Tp&&) = delete;
^
p738.cpp:28:28: error: redefinition of 'cref'
template<class T> void cref(const T&&) = delete;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/refwrap.h:378:10: note: previous definition is here
void cref(const _Tp&&) = delete;
^
p738.cpp:32:20: error: template parameter redefines default argument
template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:146:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:32:58: error: template parameter redefines default argument
template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:149:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:32:97: error: template parameter redefines default argument
template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:152:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:32:141: error: template parameter redefines default argument
template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:155:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:32:182: error: template parameter redefines default argument
template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:158:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:32:223: error: template parameter redefines default argument
template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:161:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:38:20: error: template parameter redefines default argument
template<class T = void> struct equal_to;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:330:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:39:20: error: template parameter redefines default argument
template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:333:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:39:66: error: template parameter redefines default argument
template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:336:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:39:107: error: template parameter redefines default argument
template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:339:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:39:145: error: template parameter redefines default argument
template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:342:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:39:192: error: template parameter redefines default argument
template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:345:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:46:20: error: template parameter redefines default argument
template<class T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; template<> struct logical_and<void>; template<> struct logical_or<void>; template<> struct logical_not<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:774:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:46:65: error: template parameter redefines default argument
template<class T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; template<> struct logical_and<void>; template<> struct logical_or<void>; template<> struct logical_not<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:777:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:46:109: error: template parameter redefines default argument
template<class T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; template<> struct logical_and<void>; template<> struct logical_or<void>; template<> struct logical_not<void>;
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_function.h:780:27: note: previous default template argument defined here
template<typename _Tp = void>
^
p738.cpp:50:29: error: unknown type name 'unspecified'
template<class F> constexpr unspecified not_fn(F&& f);
^
p738.cpp:52:44: error: unknown type name 'unspecified'
template<class F, class... Args> constexpr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p738.cpp -std=03 -o p738g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from N4910.h:11,
from p738.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 \
| ^~~~~
p738.cpp:18:7: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
18 | constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
| ^~~~~~~~~
p738.cpp:19:9: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
19 | noexcept(is_nothrow_invocable_v<F, Args...>);
| ^~~~~~~~
p738.cpp:17:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
17 | template<class F, class... Args>
| ^~~
p738.cpp:18:7: error: 'constexpr' does not name a type
18 | constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
| ^~~~~~~~~
p738.cpp:18:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:20:37: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
20 | template<class R, class F, class... Args>
| ^~~
p738.cpp:21:7: error: 'constexpr' does not name a type
21 | constexpr R invoke_r(F&& f, Args&&... args)
| ^~~~~~~~~
p738.cpp:21:7: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:25:23: error: 'constexpr' does not name a type
25 | template<class T> constexpr reference_wrapper<T> ref(T&) noexcept;
| ^~~~~~~~~
p738.cpp:25:23: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:26:23: error: 'constexpr' does not name a type
26 | template<class T> constexpr reference_wrapper<const T> cref(const T&) noexcept;
| ^~~~~~~~~
p738.cpp:26:23: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:27:39: error: expected ',' or '...' before '&&' token
27 | template<class T> void ref(const T&&) = delete;
| ^~
p738.cpp:27:45: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
27 | template<class T> void ref(const T&&) = delete;
| ^~~~~~
p738.cpp:28:40: error: expected ',' or '...' before '&&' token
28 | template<class T> void cref(const T&&) = delete;
| ^~
p738.cpp:28:46: warning: defaulted and deleted functions only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
28 | template<class T> void cref(const T&&) = delete;
| ^~~~~~
p738.cpp:29:23: error: 'constexpr' does not name a type
29 | template<class T> constexpr reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
| ^~~~~~~~~
p738.cpp:29:23: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:30:23: error: 'constexpr' does not name a type
30 | template<class T> constexpr reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
| ^~~~~~~~~
p738.cpp:30:23: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:50:19: error: 'constexpr' does not name a type
50 | template<class F> constexpr unspecified not_fn(F&& f);
| ^~~~~~~~~
p738.cpp:50:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:52:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
52 | template<class F, class... Args> constexpr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
| ^~~
p738.cpp:52:34: error: 'constexpr' does not name a type
52 | template<class F, class... Args> constexpr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
| ^~~~~~~~~
p738.cpp:52:34: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:52:107: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
52 | class... Args> constexpr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
| ^~~
p738.cpp:52:117: error: 'constexpr' does not name a type
52 | rgs> constexpr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
| ^~~~~~~~~
p738.cpp:52:117: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:55:10: error: 'constexpr' does not name a type
55 | inline constexpr bool is_bind_expression_v = is_bind_expression<T>::value;
| ^~~~~~~~~
p738.cpp:55:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:58:10: error: 'constexpr' does not name a type
58 | inline constexpr int is_placeholder_v = is_placeholder<T>::value;
| ^~~~~~~~~
p738.cpp:58:10: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:59:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
59 | template<class F, class... BoundArgs>
| ^~~
p738.cpp:60:1: error: 'constexpr' does not name a type
60 | constexpr unspecified bind(F&&, BoundArgs&&...);
| ^~~~~~~~~
p738.cpp:60:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:61:33: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
61 | template<class R, class F, class... BoundArgs> constexpr unspecified bind(F&&, BoundArgs&&...);
| ^~~
p738.cpp:61:48: error: 'constexpr' does not name a type
61 | template<class R, class F, class... BoundArgs> constexpr unspecified bind(F&&, BoundArgs&&...);
| ^~~~~~~~~
p738.cpp:61:48: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:64:1: error: 'see' does not name a type
64 | see below _2;
| ^~~
p738.cpp:65:1: error: expected unqualified-id before '.' token
65 | . . .
| ^
p738.cpp:68:1: error: 'constexpr' does not name a type
68 | constexpr unspecified mem_fn(R T::*) noexcept; // 22.10.17, polymorphic function wrappers
| ^~~~~~~~~
p738.cpp:68:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p738.cpp:71:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
71 | template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
| ^~~
p738.cpp:71:63: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
71 | template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
| ^~~
p738.cpp:73:31: error: 'ArgTypes' was not declared in this scope
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^~~~~~~~
p738.cpp:73:42: error: a function call cannot appear in a constant-expression
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:43: error: template argument 1 is invalid
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:58: error: 'ArgTypes' was not declared in this scope
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^~~~~~~~
p738.cpp:73:69: error: a function call cannot appear in a constant-expression
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:70: error: template argument 1 is invalid
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:74: error: expected initializer before 'noexcept'
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^~~~~~~~
p738.cpp:75:43: error: 'ArgTypes' was not declared in this scope
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^~~~~~~~
p738.cpp:75:54: error: a function call cannot appear in a constant-expression
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^
p738.cpp:75:55: error: template argument 1 is invalid
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^
p738.cpp:75:59: error: 'nullptr_t' has not been declared
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^~~~~~~~~
p738.cpp:75:70: error: expected initializer before 'noexcept'
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^~~~~~~~
p738.cpp:77:15: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
77 | template<class... S> class move_only_function; // not defined template<class R, class... ArgTypes>
| ^~~
p738.cpp:78:28: error: 'ArgTypes' was not declared in this scope
78 | class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
| ^~~~~~~~
p738.cpp:78:39: error: a function call cannot appear in a constant-expression
78 | class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
| ^
p738.cpp:78:63: error: template argument 1 is invalid
78 | class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
| ^
p738.cpp:80:66: error: spurious '>>', use '>' to terminate a template argument list
80 | template<class ForwardIterator, class BinaryPredicate = equal_to<>>
| ^~
p738.cpp:80:57: error: two or more data types in declaration of 'type name'
80 | template<class ForwardIterator, class BinaryPredicate = equal_to<>>
| ^~~~~~~~~~~
p738.cpp:81:32: error: expected '>' before ';' token
81 | class default_searcher;
| ^
p738.cpp:81:32: error: expected unqualified-id before ';' token
p738.cpp:83:30: error: 'hash' does not name a type
83 | class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
| ^~~~
p738.cpp:83:34: error: expected '>' before '<' token
83 | class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
| ^
p738.cpp:85:36: error: expected unqualified-id before ';' token
85 | class boyer_moore_searcher;
| ^
p738.cpp:87:30: error: 'hash' does not name a type
87 | class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
| ^~~~
p738.cpp:87:34: error: expected '>' before '<' token
87 | class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
| ^
p738.cpp:89:45: error: expected unqualified-id before ';' token
89 | class boyer_moore_horspool_searcher;
| ^
p738.cpp:101:15: error: expected constructor, destructor, or type conversion before '(' token
101 | transform(a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
| ^
p738.cpp:103:15: error: expected constructor, destructor, or type conversion before '(' token
103 | transform(a.begin(), a.end(), a.begin(), negate<double>());
| ^
$ g++ p738.cpp -std=2b -o p738g -I. -Wall
p738.cpp:27:28: error: redefinition of 'template<class T> void std::ref(const T&&)'
27 | template<class T> void ref(const T&&) = delete;
| ^~~
In file included from /usr/local/include/c++/12.1.0/string:51,
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 p738.cpp:10:
/usr/local/include/c++/12.1.0/bits/refwrap.h:384:10: note: 'template<class _Tp> void std::ref(const _Tp&&)' previously declared here
384 | void ref(const _Tp&&) = delete;
| ^~~
p738.cpp:28:28: error: redefinition of 'template<class T> void std::cref(const T&&)'
28 | template<class T> void cref(const T&&) = delete;
| ^~~~
/usr/local/include/c++/12.1.0/bits/refwrap.h:387:10: note: 'template<class _Tp> void std::cref(const _Tp&&)' previously declared here
387 | void cref(const _Tp&&) = delete;
| ^~~~
p738.cpp:32:10: error: redefinition of default argument for 'class T'
32 | template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
| ^~~~~
In file included from /usr/local/include/c++/12.1.0/string:48:
/usr/local/include/c++/12.1.0/bits/stl_function.h:159:12: note: original definition appeared here
159 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:32:48: error: redefinition of default argument for 'class T'
32 | template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:162:12: note: original definition appeared here
162 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:32:87: error: redefinition of default argument for 'class T'
32 | template<class T = void> struct plus; template<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:165:12: note: original definition appeared here
165 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:32:131: error: redefinition of default argument for 'class T'
32 | late<class T = void> struct minus; template<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:168:12: note: original definition appeared here
168 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:32:172: error: redefinition of default argument for 'class T'
32 | te<class T = void> struct multiplies; template<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:171:12: note: original definition appeared here
171 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:32:213: error: redefinition of default argument for 'class T'
32 | plate<class T = void> struct divides; template<class T = void> struct modulus; template<class T = void> struct negate; template<> struct plus<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:174:12: note: original definition appeared here
174 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:38:10: error: redefinition of default argument for 'class T'
38 | template<class T = void> struct equal_to;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:349:12: note: original definition appeared here
349 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:39:10: error: redefinition of default argument for 'class T'
39 | template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:352:12: note: original definition appeared here
352 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:39:56: error: redefinition of default argument for 'class T'
39 | template<class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:355:12: note: original definition appeared here
355 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:39:97: error: redefinition of default argument for 'class T'
39 | <class T = void> struct not_equal_to; template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:358:12: note: original definition appeared here
358 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:39:135: error: redefinition of default argument for 'class T'
39 | template<class T = void> struct greater; template<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:361:12: note: original definition appeared here
361 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:39:182: error: redefinition of default argument for 'class T'
39 | te<class T = void> struct less; template<class T = void> struct greater_equal; template<class T = void> struct less_equal; template<> struct equal_to<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:364:12: note: original definition appeared here
364 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:46:10: error: redefinition of default argument for 'class T'
46 | template<class T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; template<> struct logical_and<void>; template<> struct logical_or<void>; template<> struct logical_not<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:781:12: note: original definition appeared here
781 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:46:55: error: redefinition of default argument for 'class T'
46 | template<class T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; template<> struct logical_and<void>; template<> struct logical_or<void>; template<> struct logical_not<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:784:12: note: original definition appeared here
784 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:46:99: error: redefinition of default argument for 'class T'
46 | lass T = void> struct logical_and; template<class T = void> struct logical_or; template<class T = void> struct logical_not; template<> struct logical_and<void>; template<> struct logical_or<void>; template<> struct logical_not<void>;
| ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_function.h:787:12: note: original definition appeared here
787 | template<typename _Tp = void>
| ^~~~~~~~
p738.cpp:50:29: error: 'unspecified' does not name a type
50 | template<class F> constexpr unspecified not_fn(F&& f);
| ^~~~~~~~~~~
p738.cpp:52:44: error: 'unspecified' does not name a type
52 | template<class F, class... Args> constexpr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
| ^~~~~~~~~~~
p738.cpp:52:127: error: 'unspecified' does not name a type
52 | expr unspecified bind_front(F&&, Args&&...); template<class F, class... Args> constexpr unspecified bind_back(F&&, Args&&...);
| ^~~~~~~~~~~
p738.cpp:60:11: error: 'unspecified' does not name a type
60 | constexpr unspecified bind(F&&, BoundArgs&&...);
| ^~~~~~~~~~~
p738.cpp:61:58: error: 'unspecified' does not name a type
61 | template<class R, class F, class... BoundArgs> constexpr unspecified bind(F&&, BoundArgs&&...);
| ^~~~~~~~~~~
p738.cpp:64:1: error: 'see' does not name a type
64 | see below _2;
| ^~~
p738.cpp:65:1: error: expected unqualified-id before '.' token
65 | . . .
| ^
p738.cpp:68:11: error: 'unspecified' does not name a type
68 | constexpr unspecified mem_fn(R T::*) noexcept; // 22.10.17, polymorphic function wrappers
| ^~~~~~~~~~~
p738.cpp:73:31: error: 'ArgTypes' was not declared in this scope
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^~~~~~~~
p738.cpp:73:29: error: 'R' was not declared in this scope
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:43: error: template argument 1 is invalid
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:58: error: 'ArgTypes' was not declared in this scope
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^~~~~~~~
p738.cpp:73:56: error: 'R' was not declared in this scope
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:73:70: error: template argument 1 is invalid
73 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
| ^
p738.cpp:75:43: error: 'ArgTypes' was not declared in this scope
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^~~~~~~~
p738.cpp:75:41: error: 'R' was not declared in this scope
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^
p738.cpp:75:55: error: template argument 1 is invalid
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^
p738.cpp:75:15: error: 'bool std::operator==(const int&, nullptr_t)' must have an argument of class or enumerated type
75 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
| ^~~~~~~~
p738.cpp:78:28: error: 'ArgTypes' was not declared in this scope
78 | class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
| ^~~~~~~~
p738.cpp:78:26: error: 'R' was not declared in this scope
78 | class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
| ^
p738.cpp:78:63: error: template argument 1 is invalid
78 | class move_only_function<R(ArgTypes...) cv ref noexcept(noex )>; // see below
| ^
p738.cpp:91:8: error: class template 'hash' redeclared as non-template
91 | struct hash;
| ^~~~
In file included from /usr/local/include/c++/12.1.0/string_view:43,
from /usr/local/include/c++/12.1.0/bits/basic_string.h:48,
from /usr/local/include/c++/12.1.0/string:53:
/usr/local/include/c++/12.1.0/bits/functional_hash.h:59:12: note: previous declaration here
59 | struct hash;
| ^~~~
p738.cpp:101:15: error: expected constructor, destructor, or type conversion before '(' token
101 | transform(a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
| ^
p738.cpp:103:15: error: expected constructor, destructor, or type conversion before '(' token
103 | transform(a.begin(), a.end(), a.begin(), negate<double>());
| ^
検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。
参考資料(reference)
@kazuo_reve 私が効果を確認した「小川メソッド」
自己参照(self reference)
関連する自己参照以外は、こちらの先頭に移転。
C言語(C++)に対する誤解、曲解、無理解、爽快。
#include "N4910.h"
C++N4910資料の改善点
ockerにclang
docker gnu(gcc/g++) and llvm(clang/clang++)
コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
C++N4910:2022 tag follower 200人超えました。ありがとうございます。
C++N4910:2022 tag follower 200人超えました。ありがとうございます。
コピペコンパイルエラーあるある
C++ Error Message Collection(1)does not name a type, 11 articles
dockerにclang
docker gnu(gcc/g++) and llvm(clang/clang++)
Compare the contents of C++N4910:2022, C++N4741:2018 and C++N4606:2015
C++ sample list
clang++, g++コンパイルエラー方針の違いの例
astyle 使ってみた
DoCAP(ドゥーキャップ)って何ですか?
小川メソッド 覚え(書きかけ)
<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
文書履歴(document history)
ver. 0.01 初稿 20220730