0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

28.4 Complex numbers [complex.numbers] C++N4910:2022 (667) p1270.cpp

Last updated at Posted at 2022-08-17

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

28.4 Complex numbers [complex.numbers] C++N4910:2022 (667) p1270.cpp

算譜(source code)

p1270.cpp
// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "28.4 Complex numbers [complex.numbers] C++N4910:2022 (667) p1270.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;

// 28.4.1 General [complex.numbers.general]
//  The header <complex> defines a class template, and numerous functions for representing and manipulating complex numbers.
//  The effect of instantiating the template complex for any type other than float, double, or long double is unspecified. The specializations complex<float>, complex<double>, and complex<long double> are literal types (6.8.1).
//  If the result of a function is not mathematically defined or not in the range of representable values for its type, the behavior is undefined.
//  If z is an lvalue of type cv complex<T> then:
// Moreover, if a is an expression of type cv complex<T>* and the expression a[i] is well-defined for an integer expression i, then:
// — reinterpret_cast<cv T*>(a)[2*i] designates the real part of a[i], and
// — reinterpret_cast<cv T*>(a)[2*i + 1] designates the imaginary part of a[i].
// 28.4.2 Header <complex> synopsis [complex.syn]
namespace std {
// 28.4.3, class template complex template<class T> class complex;
// 28.4.4, specializations
template<> class complex<float>;
template<> class complex<double>;
template<> class complex<long double>;
// 28.4.7, operators
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&);
template<class T> constexpr complex<T> operator+(const complex<T>&, const T&);
template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
template<class T> constexpr complex<T> operator-(const complex<T>&, const complex<T>&);
template<class T> constexpr complex<T> operator-(const complex<T>&, const T&);
template<class T> constexpr complex<T> operator-(const T&, const complex<T>&);
template<class T> constexpr complex<T> operator*(const complex<T>&, const complex<T>&);
template<class T> constexpr complex<T> operator*(const complex<T>&, const T&);
template<class T> constexpr complex<T> operator*(const T&, const complex<T>&);
template<class T> constexpr complex<T> operator/(const complex<T>&, const complex<T>&);
template<class T> constexpr complex<T> operator/(const complex<T>&, const T&);
template<class T> constexpr complex<T> operator/(const T&, const complex<T>&);
template<class T> constexpr complex<T> operator+(const complex<T>&);
template<class T> constexpr complex<T> operator-(const complex<T>&);
template<class T> constexpr bool operator==(const complex<T>&, const complex<T>&);
template<class T> constexpr bool operator==(const complex<T>&, const T&);
template<class T, class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, complex<T>&);
template<class T, class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const complex<T>&);
// 28.4.8, values
template<class T> constexpr T real(const complex<T>&);
template<class T> constexpr T imag(const complex<T>&);
template<class T> T abs(const complex<T>&);
template<class T> T arg(const complex<T>&);
template<class T> constexpr T norm(const complex<T>&);
template<class T> constexpr complex<T> conj(const complex<T>&);
template<class T> complex<T> proj(const complex<T>&);
template<class T> complex<T> polar(const T&, const T& = T());
// 28.4.9, transcendentals
template<class T> complex<T> acos(const complex<T>&);
template<class T> complex<T> asin(const complex<T>&);
template<class T> complex<T> atan(const complex<T>&);
template<class T> complex<T> acosh(const complex<T>&);
template<class T> complex<T> asinh(const complex<T>&);
template<class T> complex<T> atanh(const complex<T>&);
template<class T> complex<T> cos  (const complex<T>&);
template<class T> complex<T> cosh (const complex<T>&);
template<class T> complex<T> exp  (const complex<T>&);
template<class T> complex<T> log  (const complex<T>&);
template<class T> complex<T> log10(const complex<T>&);
template<class T> complex<T> pow  (const complex<T>&, const T&);
template<class T> complex<T> pow  (const complex<T>&, const complex<T>&);
template<class T> complex<T> pow  (const T&, const complex<T>&);
template<class T> complex<T> sin  (const complex<T>&);
template<class T> complex<T> sinh (const complex<T>&);
template<class T> complex<T> sqrt (const complex<T>&);
template<class T> complex<T> tan  (const complex<T>&);
template<class T> complex<T> tanh (const complex<T>&);
// 28.4.11, complex literals
inline namespace literals {
inline namespace complex_literals {
constexpr complex<long double> operator""il(long double);
constexpr complex<long double> operator""il(unsigned long long);
constexpr complex<double> operator""i(long double);
constexpr complex<double> operator""i(unsigned long long);
constexpr complex<float> operator""if(long double);
constexpr complex<float> operator""if(unsigned long long);
}
}
}
// 28.4.3 Class template complex
namespace std {
template<class T> class complex {
public:
    using value_type = T;
    constexpr complex(const T& re = T(), const T& im = T());
    constexpr complex(const complex&);
    template<class X> constexpr complex(const complex<X>&);
    constexpr T real() const;
    constexpr void real(T);
    constexpr T imag() const;
    constexpr void imag(T);
    constexpr complex& operator= (const T&);
    constexpr complex& operator+=(const T&);
    constexpr complex& operator-=(const T&);
    constexpr complex& operator*=(const T&);
    constexpr complex& operator/=(const T&);
    constexpr complex& operator=(const complex&);
    template<class X> constexpr complex& operator= (const complex<X>&);
    template<class X> constexpr complex& operator+=(const complex<X>&);
    template<class X> constexpr complex& operator-=(const complex<X>&);
    template<class X> constexpr complex& operator*=(const complex<X>&);
    template<class X> constexpr complex& operator/=(const complex<X>&);
};
}
//  The class complex describes an object that can store the Cartesian components, real() and imag(), of a complex number.
// 28.4.4 Specializations [complex.special]
namespace std {
template<> class complex<float> {
public:
    using value_type = float;
    constexpr complex(float re = 0.0f, float im = 0.0f);
    constexpr complex(const complex<float>&) = default;
    constexpr explicit complex(const complex<double>&);
    constexpr explicit complex(const complex<long double>&);
    constexpr float real() const;
    constexpr void real(float);
    constexpr float imag() const;
    constexpr void imag(float);
    constexpr complex& operator= (float);
    constexpr complex& operator+=(float);
    constexpr complex& operator-=(float);
    constexpr complex& operator*=(float);
    constexpr complex& operator/=(float);
    constexpr complex& operator=(const complex&);
    template<class X> constexpr complex& operator= (const complex<X>&);
    template<class X> constexpr complex& operator+=(const complex<X>&);
    template<class X> constexpr complex& operator-=(const complex<X>&);
    template<class X> constexpr complex& operator*=(const complex<X>&);
    template<class X> constexpr complex& operator/=(const complex<X>&);
};
template<> class complex<double> {
public:
    using value_type = double;
    constexpr complex(double re = 0.0, double im = 0.0);
    constexpr complex(const complex<float>&);
    constexpr complex(const complex<double>&) = default;
    constexpr explicit complex(const complex<long double>&);
    constexpr double real() const;
    constexpr void real(double);
    constexpr double imag() const;
    constexpr void imag(double);
    constexpr complex& operator= (double);
    constexpr complex& operator+=(double);
    constexpr complex& operator-=(double);
    constexpr complex& operator*=(double);
    constexpr complex& operator/=(double);
    constexpr complex& operator=(const complex&);
    template<class X> constexpr complex& operator= (const complex<X>&);
    template<class X> constexpr complex& operator+=(const complex<X>&);
    template<class X> constexpr complex& operator-=(const complex<X>&);
    template<class X> constexpr complex& operator*=(const complex<X>&);
    template<class X> constexpr complex& operator/=(const complex<X>&);
};
template<> class complex<long double> {
public:
    using value_type = long double;
    constexpr complex(long double re = 0.0L, long double im = 0.0L);
    constexpr complex(const complex<float>&);
    constexpr complex(const complex<double>&);
    constexpr complex(const complex<long double>&) = default;
    constexpr long double real() const;
    constexpr void real(long double);
    constexpr long double imag() const;
    constexpr void imag(long double);
    constexpr complex& operator= (long double);
    constexpr complex& operator+=(long double);
    constexpr complex& operator-=(long double);
    constexpr complex& operator*=(long double);
    constexpr complex& operator/=(long double);
    constexpr complex& operator=(const complex&);
    template<class X> constexpr complex& operator= (const complex<X>&);
    template<class X> constexpr complex& operator+=(const complex<X>&);
    template<class X> constexpr complex& operator-=(const complex<X>&);
    template<class X> constexpr complex& operator*=(const complex<X>&);
    template<class X> constexpr complex& operator/=(const complex<X>&);
};
}
// 28.4.5 Member functions [complex.members]
template<class T> constexpr complex(const T& re = T(), const T& im = T());
// Postconditions: real() == re && imag() == im is true. constexpr T real() const;
// Returns: The value of the real component. constexpr void real(T val);
// Effects: Assigns val to the real component. constexpr T imag() const;
// Returns: The value of the imaginary component. constexpr void imag(T val);
// Effects: Assigns val to the imaginary component.
// 28.4.6 Member operators [complex.member.ops]
constexpr complex& operator+=(const T& rhs);
// Effects: Adds the scalar value rhs to the real part of the complex value *this and stores the result in the real part of *this, leaving the imaginary part unchanged.
// Returns: *this.
constexpr complex& operator-=(const T& rhs);
// Effects: Subtracts the scalar value rhs from the real part of the complex value *this and stores the result in the real part of *this, leaving the imaginary part unchanged.
// Returns: *this.
constexpr complex& operator*=(const T& rhs);
// Effects: Multiplies the scalar value rhs by the complex value *this and stores the result in *this. Returns: *this.
constexpr complex& operator/=(const T& rhs);
// Effects: Divides the scalar value rhs into the complex value *this and stores the result in *this. Returns: *this.
template<class X> constexpr complex& operator+=(const complex<X>& rhs);
// Effects: Adds the complex value rhs to the complex value *this and stores the sum in *this. Returns: *this.
template<class X> constexpr complex& operator-=(const complex<X>& rhs);
// Effects: Subtracts the complex value rhs from the complex value *this and stores the difference in *this.
// Returns: *this.
template<class X> constexpr complex& operator*=(const complex<X>& rhs);
// Effects: Multiplies the complex value rhs by the complex value *this and stores the product in *this. Returns: *this.
template<class X> constexpr complex& operator/=(const complex<X>& rhs);
// Effects: Divides the complex value rhs into the complex value *this and stores the quotient in *this. Returns: *this.
// 28.4.7 Non-member operations [comple.ops]
template<class T> constexpr complex<T> operator+(const complex<T>& lhs);
// Returns: complex<T>(lhs).
template<class T> constexpr complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr complex<T> operator+(const complex<T>& lhs, const T& rhs);
template<class T> constexpr complex<T> operator+(const T& lhs, const complex<T>& rhs);
// Returns: complex<T>(lhs) += rhs.
template<class T> constexpr complex<T> operator-(const complex<T>& lhs);
// Returns: complex<T>(-lhs.real(),-lhs.imag()).
template<class T> constexpr complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr complex<T> operator-(const complex<T>& lhs, const T& rhs);
template<class T> constexpr complex<T> operator-(const T& lhs, const complex<T>& rhs);
// Returns: complex<T>(lhs) -= rhs.
template<class T> constexpr complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr complex<T> operator*(const complex<T>& lhs, const T& rhs);
template<class T> constexpr complex<T> operator*(const T& lhs, const complex<T>& rhs);
// Returns: complex<T>(lhs) *= rhs.
template<class T> constexpr complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr complex<T> operator/(const complex<T>& lhs, const T& rhs);
template<class T> constexpr complex<T> operator/(const T& lhs, const complex<T>& rhs);
// Returns: complex<T>(lhs) /= rhs.
template<class T> constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs);
template<class T> constexpr bool operator==(const complex<T>& lhs, const T& rhs);
// Returns: lhs.real() == rhs.real() && lhs.imag() == rhs.imag(). Remarks: The imaginary part is assumed to be T(), or 0.0, for the T arguments.
template<class T, class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& is, complex<T>& x);
// Preconditions: The input values are convertible to T.
// Effects: Extracts a complex number x of the form: u, (u), or (u,v), where u is the real part and v is the imaginary part (31.7.4.3). If bad input is encountered, calls is.setstate(ios_base::failbit) (which may throw ios_base::failure (31.5.4.4)).
// Returns: is.
// Remarks: This extraction is performed as a series of simpler extractions. Therefore, the skipping of whitespace is specified to be the same for each of the simpler extractions.
template<class T, class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& o, const complex<T>& x);
// Effects: Inserts the complex number x onto the stream o as if it were implemented as follows:
basic_ostringstream<charT, traits> s;
s.flags(o.flags());
s.imbue(o.getloc());
s.precision(o.precision());
s << '(' << x.real() << "," << x.imag() << ')';
return o << s.str();
// [Note 1: In a locale in which comma is used as a decimal point character, the use of comma as a field separator can be ambiguous. Inserting showpoint into the output stream forces all outputs to show an explicit decimal point character; as a result, all inserted sequences of complex numbers can be extracted unambiguously.
// 28.4.8 Value operations [complex.value.ops]
template<class T> constexpr T real(const complex<T>& x);
// Returns: x.real().
template<class T> constexpr T imag(const complex<T>& x);
// Returns: x.imag().
template<class T> T abs(const complex<T>& x);
// Returns: The magnitude of x. template<class T> T arg(const complex<T>& x);
// Returns: The phase angle of x, or atan2(imag(x), real(x)). template<class T> constexpr T norm(const complex<T>& x);
// Returns: The squared magnitude of x.
template<class T> constexpr complex<T> conj(const complex<T>& x);
// Returns: The complex conjugate of x.
template<class T> complex<T> proj(const complex<T>& x);
// Returns: The projection of x onto the Riemann sphere. Remarks: Behaves the same as the C function cproj. See also: ISO C 7.3.9.5 ISO C 7.3.5.1 ISO C 7.3.5.2 ISO C 7.3.5.3 ISO C 7.3.6.1
template<class T> complex<T> polar(const T& rho, const T& theta = T());
// Preconditions: rho is non-negative and non-NaN. theta is finite.
// Returns: The complex value corresponding to a complex number whose magnitude is rho and whose phase angle is theta.
// 28.4.9 Transcendentals [complex.transcendentals]
template<class T> complex<T> acos(const complex<T>& x);
// Returns: The complex arc cosine of x.
// Remarks: Behaves the same as the C function cacos. See also:
template<class T> complex<T> asin(const complex<T>& x);
// Returns: The complex arc sine of x.
// Remarks: Behaves the same as the C function casin. See also:
template<class T> complex<T> atan(const complex<T>& x);
// Returns: The complex arc tangent of x.
// Remarks: Behaves the same as the C function catan. See also:
template<class T> complex<T> acosh(const complex<T>& x);
// Returns: The complex arc hyperbolic cosine of x.
// Remarks: Behaves the same as the C function cacosh. See also:
template<class T> complex<T> asinh(const complex<T>& x);
//  The following function templates shall have additional overloads:
// Returns: The complex arc hyperbolic sine of x.
// Remarks: Behaves the same as the C function casinh. See also: ISO C 7.3.6.2 ISO C 7.3.6.3
template<class T> complex<T> atanh(const complex<T>& x);
// Returns: The complex arc hyperbolic tangent of x.
// Remarks: Behaves the same as the C function catanh. See also:
template<class T> complex<T> cos(const complex<T>& x);
// Returns: The complex cosine of x.
template<class T> complex<T> cosh(const complex<T>& x);
// Returns: The complex hyperbolic cosine of x. template<class T> complex<T> exp(const complex<T>& x);
// Returns: The complex base-e exponential of x. template<class T> complex<T> log(const complex<T>& x);
// Returns: The complex natural (base-e) logarithm of x. For all x, imag(log(x)) lies in the interval [−π, π].
// [Note 1: The semantics of this function are intended to be the same in C++ as they are for clog in C.
// Remarks: The branch cuts are along the negative real axis.
template<class T> complex<T> log10(const complex<T>& x);
// Returns: The complex common (base-10) logarithm of x, defined as log(x) / log(10). Remarks: The branch cuts are along the negative real axis.
template<class T> complex<T> pow(const complex<T>& x, const complex<T>& y);
template<class T> complex<T> pow(const complex<T>& x, const T& y);
template<class T> complex<T> pow(const T& x, const complex<T>& y);
// Returns: The complex power of base x raised to the yth power, defined as exp(y * log(x)). The value returned for pow(0, 0) is implementation-defined.
// Remarks: The branch cuts are along the negative real axis. template<class T> complex<T> sin(const complex<T>& x);
// Returns: The complex sine of x.
template<class T> complex<T> sinh(const complex<T>& x);
// Returns: The complex hyperbolic sine of x.
template<class T> complex<T> sqrt(const complex<T>& x);
// Returns: The complex square root of x, in the range of the right half-plane.
// [Note 2: The semantics of this function are intended to be the same in C++ as they are for csqrt in C.
// Remarks: The branch cuts are along the negative real axis.
template<class T> complex<T> tan(const complex<T>& x);
// Returns: The complex tangent of x.
template<class T> complex<T> tanh(const complex<T>& x);
// Returns: The complex hyperbolic tangent of x.
// 28.4.10 Additional overloads [cmplx.over]
// — If the argument has type long double, then it is effectively cast to complex<long double>.
// — Otherwise, if the argument has type double or an integer type, then it is effectively cast to complex<double>.
// — Otherwise, if the argument has type float, then it is effectively cast to complex<float>.
// — If either argument has type complex<long double> or type long double, then both arguments are of type complex<T>:
//     arg                   norm
//     conj                  proj
//     imag                  real
// where norm, conj, imag, and real are constexpr overloads. 2 The additional overloads shall be sufficient to ensure:
// Function template pow shall have additional overloads sufficient to ensure, for a call with at least one argument
//  This subclause describes literal suffixes for constructing complex number literals. The suffixes i, il, and if create complex numbers of the types complex<double>, complex<long double>, and complex<float> respectively, with their imaginary part denoted by the given literal number and the real part being zero.
// — Otherwise, if either argument has type complex<double>, double, or an integer type, then both effectively cast to complex<long double>. arguments are effectively cast to complex<double>.
// — Otherwise, if either argument has type complex<float> or float, then both arguments are effectively cast to complex<float>.
// 28.4.11 Suffixes for complex number literals [complex.literals]
constexpr complex<long double> operator""il(long double d);
constexpr complex<long double> operator""il(unsigned long long d);
// Returns: complex<long double>{0.0L, static_cast<long double>(d)}. constexpr complex<double> operator""i(long double d);
constexpr complex<double> operator""i(unsigned long long d);
// Returns: complex<double>{0.0, static_cast<double>(d)}. constexpr complex<float> operator""if(long double d);
constexpr complex<float> operator""if(unsigned long long d);
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}```

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

```ubuntu:bash
$ clang++ p1270.cpp -std=03 -o p1270l -I. -Wall
In file included from p1270.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 \
 ^
p1270.cpp:28:19: error: unknown type name 'constexpr'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                  ^
p1270.cpp:28:29: error: no variable template matches partial specialization
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                            ^
p1270.cpp:28:39: error: expected ';' at end of declaration
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                      ^
                                      ;
p1270.cpp:28:64: error: use of undeclared identifier 'T'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                               ^
p1270.cpp:28:83: error: use of undeclared identifier 'T'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                  ^
p1270.cpp:28:40: error: C++ requires a type specifier for all declarations
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                       ^
p1270.cpp:28:107: error: unknown type name 'constexpr'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                          ^
p1270.cpp:28:117: error: no variable template matches partial specialization
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                    ^
p1270.cpp:28:127: error: expected ';' at end of declaration
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                              ^
                                                                                                                              ;
p1270.cpp:28:152: error: use of undeclared identifier 'T'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                       ^
p1270.cpp:28:163: error: unknown type name 'T'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                  ^
p1270.cpp:28:128: error: C++ requires a type specifier for all declarations
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                               ^
p1270.cpp:28:186: error: unknown type name 'constexpr'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                                         ^
p1270.cpp:28:196: error: no variable template matches partial specialization
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                                                   ^
p1270.cpp:28:206: error: expected ';' at end of declaration
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                                                             ^
                                                                                                                                                                                                             ;
p1270.cpp:28:223: error: unknown type name 'T'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                                                                              ^
p1270.cpp:28:241: error: use of undeclared identifier 'T'
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                                                                                                ^
p1270.cpp:28:207: error: C++ requires a type specifier for all declarations
template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
                                                                                                                                                                                                              ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ clang++ p1270.cpp -std=2b -o p1270l -I. -Wall
p1270.cpp:53:55: error: redefinition of default argument
template<class T> complex<T> polar(const T&, const T& = T());
                                                      ^ ~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:83:68: note: previous definition is here
  template<typename _Tp> complex<_Tp> polar(const _Tp&, const _Tp& = 0);
                                                                   ^ ~
p1270.cpp:75:36: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    constexpr complex<long double> operator""il(long double);
                                   ^
p1270.cpp:76:36: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    constexpr complex<long double> operator""il(unsigned long long);
                                   ^
p1270.cpp:77:31: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    constexpr complex<double> operator""i(long double);
                              ^
p1270.cpp:78:31: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    constexpr complex<double> operator""i(unsigned long long);
                              ^
p1270.cpp:79:30: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    constexpr complex<float> operator""if(long double);
                             ^
p1270.cpp:80:30: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    constexpr complex<float> operator""if(unsigned long long);
                             ^
p1270.cpp:85:29: error: redefinition of 'complex'
    template<class T> class complex {
                            ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: previous definition is here
    struct complex
           ^
p1270.cpp:110:25: error: redefinition of 'complex<float>'
       template<> class complex<float> {
                        ^~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:1082:12: note: previous definition is here
    struct complex<float>
           ^
p1270.cpp:133:18: error: redefinition of 'complex<double>'
template<> class complex<double> {
                 ^~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:1227:12: note: previous definition is here
    struct complex<double>
           ^
p1270.cpp:156:18: error: redefinition of 'complex<long double>'
template<> class complex<long double> {
                 ^~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:1372:12: note: previous definition is here
    struct complex<long double>
           ^
p1270.cpp:180:32: error: deduction guide must be declared in the same scope as template 'std::complex'
   template<class T> constexpr complex(const T& re = T(), const T& im = T());
                               ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:180:32: error: deduction guide cannot be declared 'constexpr'
   template<class T> constexpr complex(const T& re = T(), const T& im = T());
                     ~~~~~~~~~ ^
p1270.cpp:180:32: error: deduction guide declaration without trailing return type
p1270.cpp:187:37: error: unknown type name 'T'
constexpr complex& operator+=(const T& rhs);
                                    ^
p1270.cpp:187:11: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
constexpr complex& operator+=(const T& rhs);
          ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:190:37: error: unknown type name 'T'
constexpr complex& operator-=(const T& rhs);
                                    ^
p1270.cpp:190:11: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
constexpr complex& operator-=(const T& rhs);
          ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:193:37: error: unknown type name 'T'
constexpr complex& operator*=(const T& rhs);
                                    ^
p1270.cpp:193:11: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
constexpr complex& operator*=(const T& rhs);
          ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:195:37: error: unknown type name 'T'
constexpr complex& operator/=(const T& rhs);
                                    ^
p1270.cpp:195:11: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
constexpr complex& operator/=(const T& rhs);
          ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:197:29: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
template<class X> constexpr complex& operator+=(const complex<X>& rhs);
                            ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:199:29: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
template<class X> constexpr complex& operator-=(const complex<X>& rhs);
                            ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
p1270.cpp:202:32: error: use of class template 'complex' requires template arguments; argument deduction not allowed in function return type
   template<class X> constexpr complex& operator*=(const complex<X>& rhs);
                               ^~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/complex:127:12: note: template is declared here
    struct complex
           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
6 warnings and 20 errors generated.

$ g++ p1270.cpp -std=03 -o p1270g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from N4910.h:11,
                 from p1270.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 \
      |  ^~~~~
p1270.cpp:28:19: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   28 | template<class T> constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:28:19: error: 'constexpr' does not name a type
p1270.cpp:28:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:28:107: error: 'constexpr' does not name a type
   28 | constexpr complex<T> operator+(const complex<T>&, const complex<T>&); template<class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
      |                                                                                         ^~~~~~~~~

p1270.cpp:28:107: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:28:186: error: 'constexpr' does not name a type
   28 | class T> constexpr complex<T> operator+(const complex<T>&, const T&); template<class T> constexpr complex<T> operator+(const T&, const complex<T>&);
      |                                                                                         ^~~~~~~~~

p1270.cpp:28:186: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:29:19: error: 'constexpr' does not name a type
   29 | template<class T> constexpr complex<T> operator-(const complex<T>&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:29:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:30:19: error: 'constexpr' does not name a type
   30 | template<class T> constexpr complex<T> operator-(const complex<T>&, const T&);
      |                   ^~~~~~~~~
p1270.cpp:30:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:31:19: error: 'constexpr' does not name a type
   31 | template<class T> constexpr complex<T> operator-(const T&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:31:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:32:19: error: 'constexpr' does not name a type
   32 | template<class T> constexpr complex<T> operator*(const complex<T>&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:32:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:33:19: error: 'constexpr' does not name a type
   33 | template<class T> constexpr complex<T> operator*(const complex<T>&, const T&);
      |                   ^~~~~~~~~
p1270.cpp:33:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:34:19: error: 'constexpr' does not name a type
   34 | template<class T> constexpr complex<T> operator*(const T&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:34:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:35:19: error: 'constexpr' does not name a type
   35 | template<class T> constexpr complex<T> operator/(const complex<T>&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:35:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:36:19: error: 'constexpr' does not name a type
   36 | template<class T> constexpr complex<T> operator/(const complex<T>&, const T&);
      |                   ^~~~~~~~~
p1270.cpp:36:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:37:19: error: 'constexpr' does not name a type
   37 | template<class T> constexpr complex<T> operator/(const T&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:37:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:38:19: error: 'constexpr' does not name a type
   38 | template<class T> constexpr complex<T> operator+(const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:38:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:39:19: error: 'constexpr' does not name a type
   39 | template<class T> constexpr complex<T> operator-(const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:39:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:40:19: error: 'constexpr' does not name a type
   40 | template<class T> constexpr bool operator==(const complex<T>&, const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:40:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:41:19: error: 'constexpr' does not name a type
   41 | template<class T> constexpr bool operator==(const complex<T>&, const T&);
      |                   ^~~~~~~~~
p1270.cpp:41:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:47:19: error: 'constexpr' does not name a type
   47 | template<class T> constexpr T real(const complex<T>&); template<class T> constexpr T imag(const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:47:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:47:74: error: 'constexpr' does not name a type
   47 | template<class T> constexpr T real(const complex<T>&); template<class T> constexpr T imag(const complex<T>&);
      |                                                                          ^~~~~~~~~
p1270.cpp:47:74: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:50:19: error: 'constexpr' does not name a type
   50 | template<class T> constexpr T norm(const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:50:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:51:19: error: 'constexpr' does not name a type
   51 | template<class T> constexpr complex<T> conj(const complex<T>&);
      |                   ^~~~~~~~~
p1270.cpp:51:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:53:30: error: redeclaration of 'template<class T> std::complex<_Tp> std::polar(const T&, const T&' may not have default arguments [-fpermissive]
   53 | template<class T> complex<T> polar(const T&, const T& = T());
      |                              ^~~~~
p1270.cpp:75:5: error: 'constexpr' does not name a type
   75 |     constexpr complex<long double> operator""il(long double);
      |     ^~~~~~~~~
p1270.cpp:75:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:76:5: error: 'constexpr' does not name a type
   76 |     constexpr complex<long double> operator""il(unsigned long long);
      |     ^~~~~~~~~
p1270.cpp:76:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:77:5: error: 'constexpr' does not name a type
   77 |     constexpr complex<double> operator""i(long double);
      |     ^~~~~~~~~
p1270.cpp:77:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:78:5: error: 'constexpr' does not name a type
   78 |     constexpr complex<double> operator""i(unsigned long long);
      |     ^~~~~~~~~
p1270.cpp:78:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:79:5: error: 'constexpr' does not name a type
   79 |     constexpr complex<float> operator""if(long double);
      |     ^~~~~~~~~
p1270.cpp:79:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:80:5: error: 'constexpr' does not name a type
   80 |     constexpr complex<float> operator""if(unsigned long long);
      |     ^~~~~~~~~
p1270.cpp:80:5: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:85:29: error: redefinition of 'class std::complex<_Tp>'
   85 |     template<class T> class complex {
      |                             ^~~~~~~
In file included from N4910.h:9:
/usr/local/include/c++/12.1.0/complex:127:11: note: previous definition of 'class std::complex<_Tp>'
  127 |     class complex
      |           ^~~~~~~
p1270.cpp:110:25: error: redefinition of 'class std::complex<float>'
  110 |        template<> class complex<float> {
      |                         ^~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/complex:1083:11: note: previous definition of 'class std::complex<float>'
 1083 |     class complex<float>
      |           ^~~~~~~~~~~~~~
p1270.cpp:133:18: error: redefinition of 'class std::complex<double>'
  133 | template<> class complex<double> {
      |                  ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/complex:1229:11: note: previous definition of 'class std::complex<double>'
 1229 |     class complex<double>
      |           ^~~~~~~~~~~~~~~
p1270.cpp:156:18: error: redefinition of 'class std::complex<long double>'
  156 | template<> class complex<long double> {
      |                  ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/complex:1375:11: note: previous definition of 'class std::complex<long double'
 1375 |     class complex<long double>
      |           ^~~~~~~~~~~~~~~~~~~~
p1270.cpp:180:22: error: 'constexpr' does not name a type
  180 |    template<class T> constexpr complex(const T& re = T(), const T& im = T());
      |                      ^~~~~~~~~
p1270.cpp:180:22: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:187:1: error: 'constexpr' does not name a type
  187 | constexpr complex& operator+=(const T& rhs);
      | ^~~~~~~~~
p1270.cpp:187:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:190:1: error: 'constexpr' does not name a type
  190 | constexpr complex& operator-=(const T& rhs);
      | ^~~~~~~~~
p1270.cpp:190:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:193:1: error: 'constexpr' does not name a type
  193 | constexpr complex& operator*=(const T& rhs);
      | ^~~~~~~~~
p1270.cpp:193:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:195:1: error: 'constexpr' does not name a type
  195 | constexpr complex& operator/=(const T& rhs);
      | ^~~~~~~~~
p1270.cpp:195:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:197:19: error: 'constexpr' does not name a type
  197 | template<class X> constexpr complex& operator+=(const complex<X>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:197:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:199:19: error: 'constexpr' does not name a type
  199 | template<class X> constexpr complex& operator-=(const complex<X>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:199:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:202:22: error: 'constexpr' does not name a type
  202 |    template<class X> constexpr complex& operator*=(const complex<X>& rhs);
      |                      ^~~~~~~~~
p1270.cpp:202:22: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:204:19: error: 'constexpr' does not name a type
  204 | template<class X> constexpr complex& operator/=(const complex<X>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:204:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:207:19: error: 'constexpr' does not name a type
  207 | template<class T> constexpr complex<T> operator+(const complex<T>& lhs);
      |                   ^~~~~~~~~
p1270.cpp:207:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:209:19: error: 'constexpr' does not name a type
  209 | template<class T> constexpr complex<T> operator+(const complex<T>& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:209:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:210:19: error: 'constexpr' does not name a type
  210 | template<class T> constexpr complex<T> operator+(const complex<T>& lhs, const T& rhs);
      |                   ^~~~~~~~~
p1270.cpp:210:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:211:19: error: 'constexpr' does not name a type
  211 | template<class T> constexpr complex<T> operator+(const T& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:211:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:213:19: error: 'constexpr' does not name a type
  213 | template<class T> constexpr complex<T> operator-(const complex<T>& lhs);
      |                   ^~~~~~~~~
p1270.cpp:213:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:215:19: error: 'constexpr' does not name a type
  215 | template<class T> constexpr complex<T> operator-(const complex<T>& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:215:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:216:19: error: 'constexpr' does not name a type
  216 | template<class T> constexpr complex<T> operator-(const complex<T>& lhs, const T& rhs);
      |                   ^~~~~~~~~
p1270.cpp:216:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:217:19: error: 'constexpr' does not name a type
  217 | template<class T> constexpr complex<T> operator-(const T& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:217:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:219:19: error: 'constexpr' does not name a type
  219 | template<class T> constexpr complex<T> operator*(const complex<T>& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:219:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:220:19: error: 'constexpr' does not name a type
  220 | template<class T> constexpr complex<T> operator*(const complex<T>& lhs, const T& rhs);
      |                   ^~~~~~~~~
p1270.cpp:220:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:221:19: error: 'constexpr' does not name a type
  221 | template<class T> constexpr complex<T> operator*(const T& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:221:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:223:19: error: 'constexpr' does not name a type
  223 | template<class T> constexpr complex<T> operator/(const complex<T>& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:223:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:224:19: error: 'constexpr' does not name a type
  224 | template<class T> constexpr complex<T> operator/(const complex<T>& lhs, const T& rhs);
      |                   ^~~~~~~~~
p1270.cpp:224:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:225:19: error: 'constexpr' does not name a type
  225 | template<class T> constexpr complex<T> operator/(const T& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:225:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:227:19: error: 'constexpr' does not name a type
  227 | template<class T> constexpr bool operator==(const complex<T>& lhs, const complex<T>& rhs);
      |                   ^~~~~~~~~
p1270.cpp:227:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:228:19: error: 'constexpr' does not name a type
  228 | template<class T> constexpr bool operator==(const complex<T>& lhs, const T& rhs);
      |                   ^~~~~~~~~
p1270.cpp:228:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:239:23: error: 'charT' was not declared in this scope; did you mean 'char'?
  239 |   basic_ostringstream<charT, traits> s;
      |                       ^~~~~
      |                       char
p1270.cpp:239:30: error: 'traits' was not declared in this scope
  239 |   basic_ostringstream<charT, traits> s;
      |                              ^~~~~~
p1270.cpp:239:36: error: template argument 1 is invalid
  239 |   basic_ostringstream<charT, traits> s;
      |                                    ^
p1270.cpp:239:36: error: template argument 2 is invalid
p1270.cpp:239:36: error: template argument 3 is invalid
p1270.cpp:240:3: error: 's' does not name a type
  240 |   s.flags(o.flags());
      |   ^
p1270.cpp:241:3: error: 's' does not name a type
  241 |   s.imbue(o.getloc());
      |   ^
p1270.cpp:242:3: error: 's' does not name a type
  242 |   s.precision(o.precision());
      |   ^
p1270.cpp:243:3: error: 's' does not name a type
  243 |   s << '(' << x.real() << "," << x.imag() << ')';
      |   ^
p1270.cpp:244:3: error: expected unqualified-id before 'return'
  244 |   return o << s.str();
      |   ^~~~~~
p1270.cpp:247:19: error: 'constexpr' does not name a type
  247 | template<class T> constexpr T real(const complex<T>& x);
      |                   ^~~~~~~~~
p1270.cpp:247:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:249:19: error: 'constexpr' does not name a type
  249 | template<class T> constexpr T imag(const complex<T>& x);
      |                   ^~~~~~~~~
p1270.cpp:249:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:255:19: error: 'constexpr' does not name a type
  255 | template<class T> constexpr complex<T> conj(const complex<T>& x);
      |                   ^~~~~~~~~
p1270.cpp:255:19: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:322:1: error: 'constexpr' does not name a type
  322 | constexpr complex<long double> operator""il(long double d);
      | ^~~~~~~~~
p1270.cpp:322:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:323:1: error: 'constexpr' does not name a type
  323 | constexpr complex<long double> operator""il(unsigned long long d);
      | ^~~~~~~~~
p1270.cpp:323:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:325:1: error: 'constexpr' does not name a type
  325 | constexpr complex<double> operator""i(unsigned long long d);
      | ^~~~~~~~~
p1270.cpp:325:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p1270.cpp:327:1: error: 'constexpr' does not name a type
  327 | constexpr complex<float> operator""if(unsigned long long d);
      | ^~~~~~~~~
p1270.cpp:327:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'

$ g++ p1270.cpp -std=2b -o p1270g -I. -Wall
p1270.cpp:53:30: error: redeclaration of 'template<class T> std::complex<_Tp> std::polar(const T&, const T&' may not have default arguments [-fpermissive]
   53 | template<class T> complex<T> polar(const T&, const T& = T());
      |                              ^~~~~
p1270.cpp:75:36: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
   75 |     constexpr complex<long double> operator""il(long double);
      |                                    ^~~~~~~~
p1270.cpp:76:36: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
   76 |     constexpr complex<long double> operator""il(unsigned long long);
      |                                    ^~~~~~~~
p1270.cpp:77:31: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
   77 |     constexpr complex<double> operator""i(long double);
      |                               ^~~~~~~~
p1270.cpp:78:31: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
   78 |     constexpr complex<double> operator""i(unsigned long long);
      |                               ^~~~~~~~
p1270.cpp:79:30: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
   79 |     constexpr complex<float> operator""if(long double);
      |                              ^~~~~~~~
p1270.cpp:80:30: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
   80 |     constexpr complex<float> operator""if(unsigned long long);
      |                              ^~~~~~~~
p1270.cpp:85:29: error: redefinition of 'class std::complex<_Tp>'
   85 |     template<class T> class complex {
      |                             ^~~~~~~
In file included from N4910.h:9,
                 from p1270.cpp:10:
/usr/local/include/c++/12.1.0/complex:127:11: note: previous definition of 'class std::complex<_Tp>'
  127 |     class complex
      |           ^~~~~~~
p1270.cpp:110:25: error: redefinition of 'class std::complex<float>'
  110 |        template<> class complex<float> {
      |                         ^~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/complex:1083:11: note: previous definition of 'class std::complex<float>'
 1083 |     class complex<float>
      |           ^~~~~~~~~~~~~~
p1270.cpp:133:18: error: redefinition of 'class std::complex<double>'
  133 | template<> class complex<double> {
      |                  ^~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/complex:1229:11: note: previous definition of 'class std::complex<double>'
 1229 |     class complex<double>
      |           ^~~~~~~~~~~~~~~
p1270.cpp:156:18: error: redefinition of 'class std::complex<long double>'
  156 | template<> class complex<long double> {
      |                  ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/c++/12.1.0/complex:1375:11: note: previous definition of 'class std::complex<long double'
 1375 |     class complex<long double>
      |           ^~~~~~~~~~~~~~~~~~~~
p1270.cpp:180:22: error: 'decl-specifier' in declaration of deduction guide
  180 |    template<class T> constexpr complex(const T& re = T(), const T& im = T());
      |                      ^~~~~~~~~
p1270.cpp:180:32: error: deduction guide for 'std::complex<_Tp>' must have trailing return type
  180 |    template<class T> constexpr complex(const T& re = T(), const T& im = T());
      |                                ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:187:37: error: 'T' does not name a type
  187 | constexpr complex& operator+=(const T& rhs);
      |                                     ^
p1270.cpp:187:11: error: deduced class type 'complex' in function return type
  187 | constexpr complex& operator+=(const T& rhs);
      |           ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:190:37: error: 'T' does not name a type
  190 | constexpr complex& operator-=(const T& rhs);
      |                                     ^
p1270.cpp:190:11: error: deduced class type 'complex' in function return type
  190 | constexpr complex& operator-=(const T& rhs);
      |           ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:193:37: error: 'T' does not name a type
  193 | constexpr complex& operator*=(const T& rhs);
      |                                     ^
p1270.cpp:193:11: error: deduced class type 'complex' in function return type
  193 | constexpr complex& operator*=(const T& rhs);
      |           ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:195:37: error: 'T' does not name a type
  195 | constexpr complex& operator/=(const T& rhs);
      |                                     ^
p1270.cpp:195:11: error: deduced class type 'complex' in function return type
  195 | constexpr complex& operator/=(const T& rhs);
      |           ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:197:29: error: deduced class type 'complex' in function return type
  197 | template<class X> constexpr complex& operator+=(const complex<X>& rhs);
      |                             ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:199:29: error: deduced class type 'complex' in function return type
  199 | template<class X> constexpr complex& operator-=(const complex<X>& rhs);
      |                             ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:202:32: error: deduced class type 'complex' in function return type
  202 |    template<class X> constexpr complex& operator*=(const complex<X>& rhs);
      |                                ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:204:29: error: deduced class type 'complex' in function return type
  204 | template<class X> constexpr complex& operator/=(const complex<X>& rhs);
      |                             ^~~~~~~
/usr/local/include/c++/12.1.0/complex:67:32: note: 'template<class _Tp> class std::complex' declared here
   67 |   template<typename _Tp> class complex;
      |                                ^~~~~~~
p1270.cpp:239:23: error: 'charT' was not declared in this scope; did you mean 'char'?
  239 |   basic_ostringstream<charT, traits> s;
      |                       ^~~~~
      |                       char
p1270.cpp:239:30: error: 'traits' was not declared in this scope
  239 |   basic_ostringstream<charT, traits> s;
      |                              ^~~~~~
p1270.cpp:239:36: error: template argument 1 is invalid
  239 |   basic_ostringstream<charT, traits> s;
      |                                    ^
p1270.cpp:239:36: error: template argument 2 is invalid
p1270.cpp:239:36: error: template argument 3 is invalid
p1270.cpp:240:3: error: 's' does not name a type
  240 |   s.flags(o.flags());
      |   ^
p1270.cpp:241:3: error: 's' does not name a type
  241 |   s.imbue(o.getloc());
      |   ^
p1270.cpp:242:3: error: 's' does not name a type
  242 |   s.precision(o.precision());
      |   ^
p1270.cpp:243:3: error: 's' does not name a type
  243 |   s << '(' << x.real() << "," << x.imag() << ')';
      |   ^
p1270.cpp:244:3: error: expected unqualified-id before 'return'
  244 |   return o << s.str();
      |   ^~~~~~
p1270.cpp:322:32: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
  322 | constexpr complex<long double> operator""il(long double d);
      |                                ^~~~~~~~
p1270.cpp:323:32: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
  323 | constexpr complex<long double> operator""il(unsigned long long d);
      |                                ^~~~~~~~
p1270.cpp:325:27: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
  325 | constexpr complex<double> operator""i(unsigned long long d);
      |                           ^~~~~~~~
p1270.cpp:327:26: warning: literal operator suffixes not preceded by '_' are reserved for future standardization [-Wliteral-suffix]
  327 | constexpr complex<float> operator""if(unsigned long long d);
      |                          ^~~~~~~~

検討事項(agenda)

コンパイルエラーを取るか、コンパイルエラーの理由を解説する。

応用例1 AUTOSAR C++

AUTOSARでC++のコーディング標準を作っている。 
MISRA-C++コーディング標準の改訂をまたずに、C++14に対応したかったためかもしれない。 

Autosar Guidelines C++14 example code compile list

応用例2 MISRA C++

MISRA C++, AUTOSAR C++について

MISRA C++ 5-0-16

応用例3 CERT C++

MISRA C/C++, AUTOSAR C++, CERT C/C++とC/C++工業標準をコンパイルする

応用例4 箱庭 

箱庭ではUnityをはじめC++を使っているらしい。 

ここでコンパイルしたコードと同じようなコードを使っているか、
ここで出たコンパイルエラーと同じようなエラーがでたかを
いろいろな版のコンパイラでコンパイルして確認していく。

仮想戦略会議「箱庭」

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる(1)

お盆には「箱庭」記事を書きましょう「もくもく会」の題材になる(2)

参考資料(reference)

エンジニア夏休み企画 個人開発

自己参考資料(self reference)

関連する自己参照以外は、こちらの先頭に移転。

C言語(C++)に対する誤解、曲解、無理解、爽快。

#include "N4910.h"

C++N4910資料の改善点

dockerにclang

docker gnu(gcc/g++) and llvm(clang/clang++)

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)

C++N4910:2022 tag follower 300人超えました。ありがとうございます。

astyle 使ってみた

【個人開発】 効率的な背景 <エンジニア夏休み企画>

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>

文書履歴(document history)

ver. 0.01 初稿  20220817

0
0
0

Register as a new user and use Qiita more conveniently

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?