はじめに(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つの情報に基づいています。
https://stackoverflow.com
https://cpprefjp.github.io
http://ja.cppreference.com/
また
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.
20.3.2.2.7 Creation [util.smartptr.shared.create] C++N4910:2022 (462) p609.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 = "20.3.2.2.7 Creation [util.smartptr.shared.create] C++N4910:2022 (462) p609.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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <coroutine>
#include <vector>
#include <complex>
#include <map>
#include <atomic>
#include <unordered_map>
#include <memory>
#include <typeinfo>
using namespace std;
//
template<class T, ...> shared_ptr<T> make_shared(args);
template<class T, class A, ...>
shared_ptr<T> allocate_shared(const A& a, args);
template<class T, ...>
shared_ptr<T> make_shared_for_overwrite(args);
template<class T, class A, ...>
shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
// Preconditions: A meets the Cpp17Allocator requirements
// Effects: Allocates memory for an object of type T (or U[N] when T is U[], where N is determined from args as specified by the concrete overload). The object is initialized from args as specified by the concrete overload. The allocate_shared and allocate_shared_for_overwrite templates use a copy of a (rebound for an unspecified value_type) to allocate memory. If an exception is thrown, the functions have no effect.
// Postconditions: r.get() != 0 && r.use_count() == 1, where r is the return value.
// Returns: A shared_ptr instance that stores and owns the address of the newly constructed object. Throws: bad_alloc, or an exception thrown from allocate or from the initialization of the object. // // Remarks: — Implementations should perform no more than one memory allocation.
// [Note 1: This provides efficiency equivalent to an intrusive smart pointer.
// — When an object of an array type U is specified to have an initial value of u (of the same type), this shall be interpreted to mean that each array element of the object has as its initial value the corresponding element from u.
// — When an object of an array type is specified to have a default initial value, this shall be interpreted to mean that each array element of the object has a default initial value.
// — When a (sub)object of a non-array type U is specified to have an initial value of v, or U(l...), where l... is a list of constructor arguments, make_shared shall initialize this (sub)object via the expression ::new(pv) U(v) or ::new(pv) U(l...) respectively, where pv has type void* and points to storage suitable to hold an object of type U.
// — When a (sub)object of a non-array type U is specified to have an initial value of v, or U(l...), where l... is a list of constructor arguments, allocate_shared shall initialize this (sub)object via the expression
// - allocator_traits<A2>::construct(a2, pv, v) or
// - allocator_traits<A2>::construct(a2, pv, l...) respectively, where pv points to storage suitable to hold an object of type U and a2 of type A2 is a rebound copy of the allocator a passed to allocate_shared such that its value_type is remove_cv_t<U>.
// — When a (sub)object of non-array type U is specified to have a default initial value, make_shared shall initialize this (sub)object via the expression ::new(pv) U(), where pv has type void* and points to storage suitable to hold an object of type U.
// — When a (sub)object of non-array type U is specified to have a default initial value, allocate_shared shall initialize this (sub)object via the expression allocator_traits<A2>::construct(a2, pv), where pv points to storage suitable to hold an object of type U and a2 of type A2 is a rebound copy of the allocator a passed to allocate_shared such that its value_type is remove_cv_t<U>.
// — When a (sub)object of non-array type U is initialized by make_shared_for_overwrite or allocate_shared_for_overwrite, it is initialized via the expression ::new(pv) U, where pv has type void* and points to storage suitable to hold an object of type U.
// — Array elements are initialized in ascending order of their addresses.
// — When the lifetime of the object managed by the return value ends, or when the initialization of an array element throws an exception, the initialized elements are destroyed in the reverse order of their original construction.
// — When a (sub)object of non-array type U that was initialized by make_shared is to be destroyed, it is destroyed via the expression pv->~U() where pv points to that object of type U.
// — When a (sub)object of non-array type U that was initialized by allocate_shared is to be destroyed, it is destroyed via the expression allocator_traits<A2>::destroy(a2, pv) where pv points to that object of type remove_cv_t<U> and a2 of type A2 is a rebound copy of the allocator a passed to allocate_shared such that its value_type is remove_cv_t<U>.
// [Note 2: These functions will typically allocate more memory than sizeof(T) to allow for internal bookkeeping structures such as reference counts.
// Constraints: T is not an array type.
// Returns: A shared_ptr to an object of type T with an initial value T(forward<Args>(args)...).
// Remarks: The shared_ptr constructors called by these functions enable shared_from_this with the address of the newly constructed object of type T.
// [Example 1:
shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
// Constraints: T is of the form U[N].
// Returns: A shared_ptr to an object of type T with a default initial value. [Example 3:
shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
template<class T, class... Args>
shared_ptr<T> make_shared(Args&&... args);
template<class T, class A, class... Args>
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
// T is not array // T is not array
// shared_ptr to vector of 16 elements with value 1 —end example]
template<class T> shared_ptr<T>
make_shared(size_t N);
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a, size_t N);
// T is U[] // T is U[]
// Constraints: T is of the form U[].
// Returns: A shared_ptr to an object of type U[N] with a default initial value, where U is remove_-extent_t<T>.
// [Example 2:
shared_ptr<double[]> p = make_shared<double[]>(1024); // shared_ptr to a value-initialized double[1024]
shared_ptr<double[][2][2]> q = make_shared<double[][2][2]>(6); // shared_ptr to a value-initialized double[6][2][2]
template<class T>
shared_ptr<T> make_shared();
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a);
// T is U[N] // T is U[N]
template<class T>
shared_ptr<T> make_shared(size_t N,
const remove_extent_t<T>& u);
shared_ptr<T> allocate_shared(const A& a, size_t N,
// T is U[]
template<class T, class A>
const remove_extent_t<T>& u); // T is U[] Constraints: T is of the form U[].
// Returns: A shared_ptr to an object of type U[N], where U is remove_extent_t<T> and each array element has an initial value of u.
// [Example 4:
shared_ptr<double[]> p = make_shared<double[]>(1024, 1.0); // shared_ptr to a double[1024], where each element is 1.0
shared_ptr<double[][2]> q = make_shared<double[][2]>(6, {1.0, 0.0});
// shared_ptr to a double[6][2], where each double[2] element is {1.0, 0.0}
shared_ptr<vector<int>[]> r = make_shared<vector<int>[]>(4, {1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
// Constraints: T is of the form U[N].
// Constraints: T is not an array of unknown bound. Returns: A shared_ptr to an object of type T. [Example 6:
struct X {
double data[1024];
};
shared_ptr<X> p = make_shared_for_overwrite<X>();
// shared_ptr to a default-initialized X, where each element in X::data has an indeterminate value shared_ptr<double[1024]> q = make_shared_for_overwrite<double[1024]>();
// shared_ptr to a default-initialized double[1024], where each element has an indeterminate value
// Constraints: T is an array of unknown bound.
// Returns: A shared_ptr to an object of type U[N], where U is remove_extent_t<T>. [Example 7:
shared_ptr<double[]> p = make_shared_for_overwrite<double[]>(1024);
// shared_ptr to a default-initialized double[1024], where each element has an indeterminate value
template<class T>
shared_ptr<T> make_shared(const remove_extent_t<T>& u);
template<class T, class A>
shared_ptr<T> allocate_shared(const A& a,
// T is U[N]
// T is U[N]
// Returns: A shared_ptr to an object of type T, where each array element of type remove_extent_t<T> has an initial value of u. [Example 5:
shared_ptr<double[1024]> p = make_shared<double[1024]>(1.0); // shared_ptr to a double[1024], where each element is 1.0
shared_ptr<double[6][2]> q = make_shared<double[6][2]>({1.0, 0.0});
// shared_ptr to a double[6][2], where each double[2] element is {1.0, 0.0}
shared_ptr<vector<int>[4]> r = make_shared<vector<int>[4]>({1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
template<class T>
shared_ptr<T> make_shared_for_overwrite();
template<class T, class A>
shared_ptr<T> allocate_shared_for_overwrite(const A& a);
const remove_extent_t<T>& u);
template<class T>
shared_ptr<T> make_shared_for_overwrite(size_t N);
template<class T, class A>
shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
編纂・実行結果(compile and go)
$ clang++ p609.cpp -std=c++03 -o p609l -I. -Wall
In file included from p609.cpp:19:
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 \
^
p609.cpp:27:22: error: expected template parameter
template<class T, ...> shared_ptr<T> make_shared(args);
^
p609.cpp:27:24: error: no template named 'shared_ptr'
template<class T, ...> shared_ptr<T> make_shared(args);
^
p609.cpp:27:50: error: use of undeclared identifier 'args'; did you mean 'arg'?
template<class T, ...> shared_ptr<T> make_shared(args);
^~~~
arg
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:652:5: note: 'arg' declared here
arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
^
p609.cpp:27:38: warning: variable templates are a C++14 extension [-Wc++14-extensions]
template<class T, ...> shared_ptr<T> make_shared(args);
^
p609.cpp:28:31: error: expected template parameter
template<class T, class A, ...>
^
p609.cpp:29:1: error: no template named 'shared_ptr'
shared_ptr<T> allocate_shared(const A& a, args);
^
p609.cpp:29:43: error: unknown type name 'args'
shared_ptr<T> allocate_shared(const A& a, args);
^
p609.cpp:30:22: error: expected template parameter
template<class T, ...>
^
p609.cpp:31:1: error: no template named 'shared_ptr'
shared_ptr<T> make_shared_for_overwrite(args);
^
p609.cpp:31:41: error: use of undeclared identifier 'args'; did you mean 'arg'?
shared_ptr<T> make_shared_for_overwrite(args);
^~~~
arg
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:652:5: note: 'arg' declared here
arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
^
p609.cpp:31:15: warning: variable templates are a C++14 extension [-Wc++14-extensions]
shared_ptr<T> make_shared_for_overwrite(args);
^
p609.cpp:32:31: error: expected template parameter
template<class T, class A, ...>
^
p609.cpp:33:1: error: no template named 'shared_ptr'
shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
^
p609.cpp:33:57: error: unknown type name 'args'
shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
^
p609.cpp:57:1: error: no template named 'shared_ptr'
shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
^
p609.cpp:60:1: error: no template named 'shared_ptr'
shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
^
p609.cpp:61:1: error: no template named 'shared_ptr'
shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
^
p609.cpp:62:24: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template<class T, class... Args>
^
p609.cpp:63:3: error: no template named 'shared_ptr'
shared_ptr<T> make_shared(Args&&... args);
^
p609.cpp:63:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
shared_ptr<T> make_shared(Args&&... args);
^
p609.cpp:64:33: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template<class T, class A, class... Args>
^
p609.cpp:65:3: error: no template named 'shared_ptr'
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
^
p609.cpp:65:49: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
^
p609.cpp:68:19: error: no template named 'shared_ptr'
template<class T> shared_ptr<T>
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
6 warnings and 20 errors generated.
rm: cannot remove 'p609l': No such file or directory
$ clang++ p609.cpp -std=c++2b -o p609l -I. -Wall
p609.cpp:27:22: error: expected template parameter
template<class T, ...> shared_ptr<T> make_shared(args);
^
p609.cpp:27:50: error: use of undeclared identifier 'args'; did you mean 'arg'?
template<class T, ...> shared_ptr<T> make_shared(args);
^~~~
arg
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:652:5: note: 'arg' declared here
arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
^
p609.cpp:28:31: error: expected template parameter
template<class T, class A, ...>
^
p609.cpp:29:43: error: unknown type name 'args'
shared_ptr<T> allocate_shared(const A& a, args);
^
p609.cpp:30:22: error: expected template parameter
template<class T, ...>
^
p609.cpp:31:41: error: use of undeclared identifier 'args'; did you mean 'arg'?
shared_ptr<T> make_shared_for_overwrite(args);
^~~~
arg
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:652:5: note: 'arg' declared here
arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
^
p609.cpp:32:31: error: expected template parameter
template<class T, class A, ...>
^
p609.cpp:33:57: error: unknown type name 'args'
shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
^
p609.cpp:57:21: error: reference to 'make_shared' is ambiguous
shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:57:21: error: reference to 'make_shared' is ambiguous
shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:60:26: error: redefinition of 'p' with a different type: 'shared_ptr<double[1024]>' vs 'shared_ptr<int>'
shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
^
p609.cpp:57:17: note: previous definition is here
shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
^
p609.cpp:60:30: error: reference to 'make_shared' is ambiguous
shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:60:30: error: reference to 'make_shared' is ambiguous
shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:61:33: error: reference to 'make_shared' is ambiguous
shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:61:33: error: reference to 'make_shared' is ambiguous
shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:63:17: error: redefinition of 'make_shared' as different kind of symbol
shared_ptr<T> make_shared(Args&&... args);
^
p609.cpp:27:38: note: previous definition is here
template<class T, ...> shared_ptr<T> make_shared(args);
^
p609.cpp:69:3: error: redefinition of 'make_shared' as different kind of symbol
make_shared(size_t N);
^
p609.cpp:27:38: note: previous definition is here
template<class T, ...> shared_ptr<T> make_shared(args);
^
p609.cpp:76:22: error: redefinition of 'p' with a different type: 'shared_ptr<double[]>' vs 'shared_ptr<int>'
shared_ptr<double[]> p = make_shared<double[]>(1024); // shared_ptr to a value-initialized double[1024]
^
p609.cpp:57:17: note: previous definition is here
shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
^
p609.cpp:76:26: error: reference to 'make_shared' is ambiguous
shared_ptr<double[]> p = make_shared<double[]>(1024); // shared_ptr to a value-initialized double[1024]
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/shared_ptr.h:872:5: note: candidate found by name lookup is 'std::make_shared'
make_shared(_Args&&... __args)
^
p609.cpp:27:38: note: candidate found by name lookup is 'make_shared'
template<class T, ...> shared_ptr<T> make_shared(args);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p609.cpp -std=c++03 -o p609g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from p609.cpp:19:
/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 \
| ^~~~~
p609.cpp:27:19: error: expected identifier before '...' token
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~
p609.cpp:27:19: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
p609.cpp:27:24: error: 'shared_ptr' does not name a type
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~
p609.cpp:28:28: error: expected identifier before '...' token
28 | template<class T, class A, ...>
| ^~~
p609.cpp:28:28: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
p609.cpp:29:1: error: 'shared_ptr' does not name a type
29 | shared_ptr<T> allocate_shared(const A& a, args);
| ^~~~~~~~~~
p609.cpp:30:19: error: expected identifier before '...' token
30 | template<class T, ...>
| ^~~
p609.cpp:30:19: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
p609.cpp:31:1: error: 'shared_ptr' does not name a type
31 | shared_ptr<T> make_shared_for_overwrite(args);
| ^~~~~~~~~~
p609.cpp:32:28: error: expected identifier before '...' token
32 | template<class T, class A, ...>
| ^~~
p609.cpp:32:28: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
p609.cpp:33:1: error: 'shared_ptr' does not name a type
33 | shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
| ^~~~~~~~~~
p609.cpp:57:1: error: 'shared_ptr' does not name a type
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^~~~~~~~~~
p609.cpp:60:1: error: 'shared_ptr' does not name a type
60 | shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
| ^~~~~~~~~~
p609.cpp:61:1: error: 'shared_ptr' does not name a type
61 | shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
| ^~~~~~~~~~
p609.cpp:62:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
62 | template<class T, class... Args>
| ^~~
p609.cpp:63:3: error: 'shared_ptr' does not name a type
63 | shared_ptr<T> make_shared(Args&&... args);
| ^~~~~~~~~~
p609.cpp:64:33: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
64 | template<class T, class A, class... Args>
| ^~~
p609.cpp:65:3: error: 'shared_ptr' does not name a type
65 | shared_ptr<T> allocate_shared(const A& a, Args&&... args);
| ^~~~~~~~~~
p609.cpp:68:19: error: 'shared_ptr' does not name a type
68 | template<class T> shared_ptr<T>
| ^~~~~~~~~~
p609.cpp:71:3: error: 'shared_ptr' does not name a type
71 | shared_ptr<T> allocate_shared(const A& a, size_t N);
| ^~~~~~~~~~
p609.cpp:76:1: error: 'shared_ptr' does not name a type
76 | shared_ptr<double[]> p = make_shared<double[]>(1024); // shared_ptr to a value-initialized double[1024]
| ^~~~~~~~~~
p609.cpp:77:1: error: 'shared_ptr' does not name a type
77 | shared_ptr<double[][2][2]> q = make_shared<double[][2][2]>(6); // shared_ptr to a value-initialized double[6][2][2]
| ^~~~~~~~~~
p609.cpp:79:3: error: 'shared_ptr' does not name a type
79 | shared_ptr<T> make_shared();
| ^~~~~~~~~~
p609.cpp:81:3: error: 'shared_ptr' does not name a type
81 | shared_ptr<T> allocate_shared(const A& a);
| ^~~~~~~~~~
p609.cpp:84:3: error: 'shared_ptr' does not name a type
84 | shared_ptr<T> make_shared(size_t N,
| ^~~~~~~~~~
p609.cpp:86:1: error: 'shared_ptr' does not name a type
86 | shared_ptr<T> allocate_shared(const A& a, size_t N,
| ^~~~~~~~~~
p609.cpp:92:1: error: 'shared_ptr' does not name a type
92 | shared_ptr<double[]> p = make_shared<double[]>(1024, 1.0); // shared_ptr to a double[1024], where each element is 1.0
| ^~~~~~~~~~
p609.cpp:93:1: error: 'shared_ptr' does not name a type
93 | shared_ptr<double[][2]> q = make_shared<double[][2]>(6, {1.0, 0.0});
| ^~~~~~~~~~
p609.cpp:93:67: error: expected unqualified-id before ')' token
93 | shared_ptr<double[][2]> q = make_shared<double[][2]>(6, {1.0, 0.0});
| ^
p609.cpp:95:1: error: 'shared_ptr' does not name a type
95 | shared_ptr<vector<int>[]> r = make_shared<vector<int>[]>(4, {1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^~~~~~~~~~
p609.cpp:95:67: error: expected unqualified-id before ')' token
95 | shared_ptr<vector<int>[]> r = make_shared<vector<int>[]>(4, {1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^
p609.cpp:99:3: error: 'shared_ptr' does not name a type
99 | shared_ptr<X> p = make_shared_for_overwrite<X>();
| ^~~~~~~~~~
p609.cpp:104:1: error: 'shared_ptr' does not name a type
104 | shared_ptr<double[]> p = make_shared_for_overwrite<double[]>(1024);
| ^~~~~~~~~~
p609.cpp:107:3: error: 'shared_ptr' does not name a type
107 | shared_ptr<T> make_shared(const remove_extent_t<T>& u);
| ^~~~~~~~~~
p609.cpp:109:3: error: 'shared_ptr' does not name a type
109 | shared_ptr<T> allocate_shared(const A& a,
| ^~~~~~~~~~
p609.cpp:114:1: error: 'shared_ptr' does not name a type
114 | shared_ptr<double[6][2]> q = make_shared<double[6][2]>({1.0, 0.0});
| ^~~~~~~~~~
p609.cpp:114:66: error: expected unqualified-id before ')' token
114 | shared_ptr<double[6][2]> q = make_shared<double[6][2]>({1.0, 0.0});
| ^
p609.cpp:116:1: error: 'shared_ptr' does not name a type
116 | shared_ptr<vector<int>[4]> r = make_shared<vector<int>[4]>({1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^~~~~~~~~~
p609.cpp:116:66: error: expected unqualified-id before ')' token
116 | shared_ptr<vector<int>[4]> r = make_shared<vector<int>[4]>({1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^
p609.cpp:118:3: error: 'shared_ptr' does not name a type
118 | shared_ptr<T> make_shared_for_overwrite();
| ^~~~~~~~~~
p609.cpp:120:3: error: 'shared_ptr' does not name a type
120 | shared_ptr<T> allocate_shared_for_overwrite(const A& a);
| ^~~~~~~~~~
p609.cpp:121:7: error: 'remove_extent_t' does not name a type
121 | const remove_extent_t<T>& u);
| ^~~~~~~~~~~~~~~
p609.cpp:123:3: error: 'shared_ptr' does not name a type
123 | shared_ptr<T> make_shared_for_overwrite(size_t N);
| ^~~~~~~~~~
p609.cpp:125:3: error: 'shared_ptr' does not name a type
125 | shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);
| ^~~~~~~~~~
rm: cannot remove 'p609g': No such file or directory
$ g++ p609.cpp -std=c++2b -o p609g -I. -Wall
p609.cpp:27:19: error: expected identifier before '...' token
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~
p609.cpp:27:50: error: 'args' was not declared in this scope
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~
p609.cpp:28:28: error: expected identifier before '...' token
28 | template<class T, class A, ...>
| ^~~
p609.cpp:29:43: error: 'args' has not been declared
29 | shared_ptr<T> allocate_shared(const A& a, args);
| ^~~~
p609.cpp:30:19: error: expected identifier before '...' token
30 | template<class T, ...>
| ^~~
p609.cpp:31:41: error: 'args' was not declared in this scope
31 | shared_ptr<T> make_shared_for_overwrite(args);
| ^~~~
p609.cpp:32:28: error: expected identifier before '...' token
32 | template<class T, class A, ...>
| ^~~
p609.cpp:33:57: error: 'args' has not been declared
33 | shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
| ^~~~
p609.cpp:57:21: error: 'make_shared' was not declared in this scope
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^~~~~~~~~~~~~~~~
p609.cpp:57:21: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
In file included from /usr/local/include/c++/12.1.0/memory:77,
from p609.cpp:21:
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:60:26: error: conflicting declaration 'std::shared_ptr<double [1024]> p'
60 | shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
| ^
p609.cpp:57:17: note: previous declaration as 'std::shared_ptr<int> p'
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^
p609.cpp:60:30: error: 'make_shared' was not declared in this scope
60 | shared_ptr<double[1024]> p = make_shared<double[1024]>(); // shared_ptr to a value-initialized double[1024]
| ^~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:60:30: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:61:33: error: 'make_shared' was not declared in this scope
61 | shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:61:33: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:63:43: error: 'template<class T, class ... Args> std::shared_ptr<_Tp> make_shared(Args&& ...)' conflicts with a previous declaration
63 | shared_ptr<T> make_shared(Args&&... args);
| ^
p609.cpp:27:38: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
p609.cpp:69:23: error: 'template<class T> std::shared_ptr<_Tp> make_shared(size_t)' conflicts with a previous declaration
69 | make_shared(size_t N);
| ^
p609.cpp:27:38: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
p609.cpp:76:22: error: conflicting declaration 'std::shared_ptr<double []> p'
76 | shared_ptr<double[]> p = make_shared<double[]>(1024); // shared_ptr to a value-initialized double[1024]
| ^
p609.cpp:57:17: note: previous declaration as 'std::shared_ptr<int> p'
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^
p609.cpp:76:26: error: 'make_shared' was not declared in this scope
76 | shared_ptr<double[]> p = make_shared<double[]>(1024); // shared_ptr to a value-initialized double[1024]
| ^~~~~~~~~~~~~~~~~~~~~
p609.cpp:76:26: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:77:28: error: conflicting declaration 'std::shared_ptr<double [][2][2]> q'
77 | shared_ptr<double[][2][2]> q = make_shared<double[][2][2]>(6); // shared_ptr to a value-initialized double[6][2][2]
| ^
p609.cpp:61:29: note: previous declaration as 'std::shared_ptr<double [6][2][2]> q'
61 | shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
| ^
p609.cpp:77:32: error: 'make_shared' was not declared in this scope
77 | shared_ptr<double[][2][2]> q = make_shared<double[][2][2]>(6); // shared_ptr to a value-initialized double[6][2][2]
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:77:32: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:79:29: error: 'template<class T> std::shared_ptr<_Tp> make_shared()' conflicts with a previous declaration
79 | shared_ptr<T> make_shared();
| ^
p609.cpp:27:38: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
p609.cpp:85:54: error: 'template<class T> std::shared_ptr<_Tp> make_shared(size_t, std::remove_extent_t<_Iter>&)' conflicts with a previous declaration
85 | const remove_extent_t<T>& u);
| ^
p609.cpp:27:38: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
p609.cpp:86:12: error: 'T' was not declared in this scope
86 | shared_ptr<T> allocate_shared(const A& a, size_t N,
| ^
p609.cpp:86:13: error: template argument 1 is invalid
86 | shared_ptr<T> allocate_shared(const A& a, size_t N,
| ^
p609.cpp:86:37: error: 'A' does not name a type
86 | shared_ptr<T> allocate_shared(const A& a, size_t N,
| ^
p609.cpp:88:1: error: expected identifier before 'template'
88 | template<class T, class A>
| ^~~~~~~~
p609.cpp:88:1: error: expected ',' or '...' before 'template'
p609.cpp:92:22: error: conflicting declaration 'std::shared_ptr<double []> p'
92 | shared_ptr<double[]> p = make_shared<double[]>(1024, 1.0); // shared_ptr to a double[1024], where each element is 1.0
| ^
p609.cpp:57:17: note: previous declaration as 'std::shared_ptr<int> p'
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^
p609.cpp:92:26: error: 'make_shared' was not declared in this scope
92 | shared_ptr<double[]> p = make_shared<double[]>(1024, 1.0); // shared_ptr to a double[1024], where each element is 1.0
| ^~~~~~~~~~~~~~~~~~~~~
p609.cpp:92:26: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:93:25: error: conflicting declaration 'std::shared_ptr<double [][2]> q'
93 | shared_ptr<double[][2]> q = make_shared<double[][2]>(6, {1.0, 0.0});
| ^
p609.cpp:61:29: note: previous declaration as 'std::shared_ptr<double [6][2][2]> q'
61 | shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
| ^
p609.cpp:93:29: error: 'make_shared' was not declared in this scope
93 | shared_ptr<double[][2]> q = make_shared<double[][2]>(6, {1.0, 0.0});
| ^~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:93:29: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:95:31: error: 'make_shared' was not declared in this scope
95 | shared_ptr<vector<int>[]> r = make_shared<vector<int>[]>(4, {1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:95:31: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:99:17: error: conflicting declaration 'std::shared_ptr<X> p'
99 | shared_ptr<X> p = make_shared_for_overwrite<X>();
| ^
p609.cpp:57:17: note: previous declaration as 'std::shared_ptr<int> p'
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^
p609.cpp:99:21: error: 'make_shared_for_overwrite' was not declared in this scope
99 | shared_ptr<X> p = make_shared_for_overwrite<X>();
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:99:21: note: suggested alternatives:
p609.cpp:31:15: note: 'make_shared_for_overwrite<T, <expression error> >'
31 | shared_ptr<T> make_shared_for_overwrite(args);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1143:5: note: 'std::make_shared_for_overwrite'
1143 | make_shared_for_overwrite(size_t __n)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:104:22: error: conflicting declaration 'std::shared_ptr<double []> p'
104 | shared_ptr<double[]> p = make_shared_for_overwrite<double[]>(1024);
| ^
p609.cpp:57:17: note: previous declaration as 'std::shared_ptr<int> p'
57 | shared_ptr<int> p = make_shared<int>(); // shared_ptr to int() shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
| ^
p609.cpp:104:26: error: 'make_shared_for_overwrite' was not declared in this scope
104 | shared_ptr<double[]> p = make_shared_for_overwrite<double[]>(1024);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:104:26: note: suggested alternatives:
p609.cpp:31:15: note: 'make_shared_for_overwrite<T, <expression error> >'
31 | shared_ptr<T> make_shared_for_overwrite(args);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1143:5: note: 'std::make_shared_for_overwrite'
1143 | make_shared_for_overwrite(size_t __n)
| ^~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:107:56: error: 'template<class T> std::shared_ptr<_Tp> make_shared(std::remove_extent_t<_Iter>&' conflicts with a previous declaration
107 | shared_ptr<T> make_shared(const remove_extent_t<T>& u);
| ^
p609.cpp:27:38: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
p609.cpp:113:30: error: there are no arguments to 'make_shared' that depend on a template parameter, so a declaration of 'make_shared' must be available [-fpermissive]
113 | shared_ptr<double[1024]> p = make_shared<double[1024]>(1.0); // shared_ptr to a double[1024], where each element is 1.0
| ^~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:113:30: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
p609.cpp:113:60: error: expected ')' before ';' token
113 | shared_ptr<double[1024]> p = make_shared<double[1024]>(1.0); // shared_ptr to a double[1024], where each element is 1.0
| ^
| )
p609.cpp:109:32: note: to match this '('
109 | shared_ptr<T> allocate_shared(const A& a,
| ^
p609.cpp:114:26: error: conflicting declaration 'std::shared_ptr<double [6][2]> q'
114 | shared_ptr<double[6][2]> q = make_shared<double[6][2]>({1.0, 0.0});
| ^
p609.cpp:61:29: note: previous declaration as 'std::shared_ptr<double [6][2][2]> q'
61 | shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>(); // shared_ptr to a value-initialized double[6][2][2]
| ^
p609.cpp:114:30: error: 'make_shared' was not declared in this scope
114 | shared_ptr<double[6][2]> q = make_shared<double[6][2]>({1.0, 0.0});
| ^~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:114:30: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:116:28: error: conflicting declaration 'std::shared_ptr<std::vector<int> [4]> r'
116 | shared_ptr<vector<int>[4]> r = make_shared<vector<int>[4]>({1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^
p609.cpp:95:27: note: previous declaration as 'std::shared_ptr<std::vector<int> []> r'
95 | shared_ptr<vector<int>[]> r = make_shared<vector<int>[]>(4, {1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^
p609.cpp:116:32: error: 'make_shared' was not declared in this scope
116 | shared_ptr<vector<int>[4]> r = make_shared<vector<int>[4]>({1, 2}); // shared_ptr to a vector<int>[4], where each vector has contents {1, 2}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:116:32: note: suggested alternatives:
p609.cpp:27:38: note: 'make_shared<T, <expression error> >'
27 | template<class T, ...> shared_ptr<T> make_shared(args);
| ^~~~~~~~~~~
/usr/local/include/c++/12.1.0/bits/shared_ptr.h:1095:5: note: 'std::make_shared'
1095 | make_shared(const remove_extent_t<_Tp>& __u)
| ^~~~~~~~~~~
p609.cpp:118:43: error: 'template<class T> std::shared_ptr<_Tp> make_shared_for_overwrite()' conflicts with a previous declaration
118 | shared_ptr<T> make_shared_for_overwrite();
| ^
p609.cpp:31:15: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared_for_overwrite<T, <expression error> >'
31 | shared_ptr<T> make_shared_for_overwrite(args);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
p609.cpp:121:23: error: 'T' was not declared in this scope
121 | const remove_extent_t<T>& u);
| ^
p609.cpp:121:24: error: template argument 1 is invalid
121 | const remove_extent_t<T>& u);
| ^
p609.cpp:121:28: error: expected initializer before ')' token
121 | const remove_extent_t<T>& u);
| ^
p609.cpp:123:51: error: 'template<class T> std::shared_ptr<_Tp> make_shared_for_overwrite(size_t)' conflicts with a previous declaration
123 | shared_ptr<T> make_shared_for_overwrite(size_t N);
| ^
p609.cpp:31:15: note: previous declaration 'template<class T, <typeprefixerror>...<anonymous> > std::shared_ptr<_Tp> make_shared_for_overwrite<T, <expression error> >'
31 | shared_ptr<T> make_shared_for_overwrite(args);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。
Script
#!/bin/sh
rm $1l
rm $1g
echo "$ clang++ $1.cpp -std=03 -o $1l -I. -Wall"
clang++ $1.cpp -std=c++03 -o $1l -I. -Wall
if [ -e $1l ]; then
./$1l
fi
rm $1l
echo "$ clang++ $1.cpp -std=2b -o $1l -I. -Wall"
clang++ $1.cpp -std=c++2b -o $1l -I. -Wall
if [ -e $1l ]; then
./$1l
fi
echo "\r"
echo "$ g++ $1.cpp -std=03 -o $1g -I. -Wall"
g++ $1.cpp -std=c++03 -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
rm $1g
echo "\r"
echo "$ g++ $1.cpp -std=2b -o $1g -I. -Wall"
g++ $1.cpp -std=c++2b -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
参考資料(reference)
cpprefjp - C++日本語リファレンス
コンパイラの実装状況
typedef は C++11 ではオワコン
C99からC++14を駆け抜けるC++講座
@kazuo_reve 私が効果を確認した「小川メソッド」
自己参照(self reference)
C++N4910:2022 tag follower 200人超えました。ありがとうございます。
DoCAP(ドゥーキャップ)って何ですか?
小川メソッド 覚え(書きかけ)
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++)
コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
Compare the contents of C++N4910:2022, C++N4741:2018 and C++N4606:2015
C++ sample list
clang++, g++コンパイルエラー方針の違いの例
astyle 使ってみた
C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1
コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da
Clang/Clang++(LLVM) gcc/g++(GNU) コンパイラ警告等比較
https://qiita.com/kaizen_nagoya/items/9a82b958cc3aeef0403f
C++2003とC++2017でコンパイルエラーになるならない事例集
https://qiita.com/kaizen_nagoya/items/a13ea3823441c430edff
Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d
cpprefjpのdecltypeをコンパイル試験
https://qiita.com/kaizen_nagoya/items/090909af702f0d5d8a67
MISRA C++ 5-0-16
https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74
C++ Templates Part1 BASICS Chapter 3. Class Templates 3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed
ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1
C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a
C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9
'wchar.h' file not found で困った clang++ macOS
https://qiita.com/kaizen_nagoya/items/de15cd46d657517fac11
Open POSIX Test Suiteの使い方を調べはじめました
https://qiita.com/kaizen_nagoya/items/644d5e407f5faf96e6dc
MISRA-C 2012 Referenceに掲載している文献の入手可能性を確認
https://qiita.com/kaizen_nagoya/items/96dc8b125e462d5575bb
どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00
MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9
「C++完全理解ガイド」の同意できること上位10
https://qiita.com/kaizen_nagoya/items/aa5744e0c4a8618c7671
<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
文書履歴(document history)
ver. 0.01 初稿 20220720