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.

22.3.2 Class template pair [pairs.pair] C++N4910:2022 (529) p670.cpp

Posted at

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

22.3.2 Class template pair [pairs.pair] C++N4910:2022 (529) p670.cpp

算譜(source code)

p670.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 = "22.3.2 Class template pair [pairs.pair] C++N4910:2022 (529) p670.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;

// Example 1
namespace std {
template<class T1, class T2>
struct pair {
    using first_type  = T1;
    using second_type = T2;
    T1 first;
    T2 second;
    pair(const pair&) = default;
    pair(pair&&) = default;
    constexpr explicit(see_below) pair();
    constexpr explicit(see_below) pair(const T1& x, const T2& y);
    template<class U1 = T1, class U2 = T2>
    constexpr explicit(see_below) pair(U1&& x, U2&& y);
    template<class U1, class U2>
    constexpr explicit(see_below) pair(pair<U1, U2>& p);
    template<class U1, class U2>
    constexpr explicit(see_below) pair(const pair<U1, U2>& p);
    template<class U1, class U2>
    constexpr explicit(see_below) pair(pair<U1, U2>&& p);
    template<class U1, class U2>
    constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
    template<class... Args1, class... Args2>
    constexpr pair(piecewise_construct_t,
                   tuple<Args1...> first_args, tuple<Args2...> second_args);
    constexpr explicit(see below) pair(const T1& x, const T2& y);
// Constraints:
// — is_copy_constructible_v<T1> is true and
// — is_copy_constructible_v<T2> is true.
// Effects: Initializes first with x and second with y.
// Remarks: The expression inside explicit is equivalent to:
    !is_convertible_v<const T1&, T1> || !is_convertible_v<const T2&, T2>
    constexpr pair& operator=(const pair& p);
    constexpr const pair& operator=(const pair& p) const;
    template<class U1, class U2>
    constexpr pair& operator=(const pair<U1, U2>& p);
    template<class U1, class U2>
    constexpr const pair& operator=(const pair<U1, U2>& p) const;
    constexpr pair& operator=(pair&& p) noexcept(see_below);
    constexpr const pair& operator=(pair&& p) const;
    template<class U1, class U2>
    constexpr pair& operator=(pair<U1, U2>&& p);
    template<class U1, class U2>
    constexpr const pair& operator=(pair<U1, U2>&& p) const;
    constexpr void swap(pair& p) noexcept(see below);
    constexpr void swap(const pair& p) const noexcept(see_below);
};
template<class T1, class T2>
pair(T1, T2) -> pair<T1, T2>;
}
//  Constructors and member functions of pair do not throw exceptions unless one of the element-wise operations specified to be called for that operation throws an exception.
//  The defaulted move and copy constructor, respectively, of pair is a constexpr function if and only if all required element-wise initializations for move and copy, respectively, would satisfy the requirements for a constexpr function.
//  If (is_trivially_destructible_v<T1> && is_trivially_destructible_v<T2>) is true, then the de- structor of pair is trivial.
//  pair<T, U> is a structural type (13.2) if T and U are both structural types. Two values p1 and p2 of type pair<T, U> are template-argument-equivalent (13.6) if and only if p1.first and p2.first are template- argument-equivalent and p1.second and p2.second are template-argument-equivalent.
constexpr explicit(see below) pair();
// Constraints:
// — is_default_constructible_v<T1> is true and
 is_default_constructible_v<T2> is true. Effects:
Value-initializes first // and second.
// Remarks: The expression inside explicit evaluates to true if and only if either T1 or T2 is not implicitly default-constructible.
// [Note 1: This behavior can be implemented with a trait that checks whether a const T1& or a const T2& can be initialized with {}.
template<class U1 = T1, class U2 = T2> constexpr explicit(see_below) pair(U1&& x, U2&& y);
// Constraints:
// — is_constructible_v<T1, U1> is true and — is_constructible_v<T2, U2> is true.
// Effects: Initializes first with std::forward<U1>(x) and second with std::forward<U2>(y).
// Remarks: The expression inside explicit is equivalent to:
!is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
// This constructor is defined as deleted if reference_constructs_from_temporary_v<first_type, U1&&> is true or reference_constructs_from_temporary_v<second_type, U2&&> is true.
tuple<Args1...> first_args, tuple<Args2...> second_args);
// Mandates:
// — is_constructible_v<T1, Args1...> is true and — is_constructible_v<T2, Args2...> is true.
// Effects: Initializes first with arguments of types Args1... obtained by forwarding the elements of first_args and initializes second with arguments of types Args2... obtained by forwarding the elements of second_args. (Here, forwarding an element x of type U within a tuple object means calling std::forward<U>(x).) This form of construction, whereby constructor arguments for first and second are each provided in a separate tuple object, is called piecewise construction.
// [Note 2: If a data member of pair is of reference type and its initialization binds it to a temporary object, the program is ill-formed (11.9.3).
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
// Let FWD (u) be static_cast<decltype(u)>(u). Constraints:
// — is_constructible_v<T1, decltype(get<0>(FWD (p)))> is true and
// — is_constructible_v<T2, decltype(get<1>(FWD (p)))> is true.
// Effects: Initializes first with get<0>(FWD (p)) and second with get<1>(FWD (p)).
// Remarks: The expression inside explicit is equivalent to:
!is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
// The constructor is defined as deleted if
reference_constructs_from_temporary_v<first_type, decltype(get<0>(FWD(p)))> || reference_constructs_from_temporary_v<second_type, decltype(get<1>(FWD(p)))>
// is true.
template<class... Args1, class... Args2>
constexpr pair(piecewise_construct_t,
          constexpr pair& operator=(const pair& p);
// Effects: Assigns p.first to first and p.second to second. Returns: *this.
// Remarks: This operator is defined as deleted unless is_copy_assignable_v<T1> is true and is_- copy_assignable_v<T2> is true.
constexpr const pair& operator=(const pair& p) const;
// Constraints:
// — is_copy_assignable_v<const T1> is true and — is_copy_assignable_v<const T2> is true.
// Effects: Assigns p.first to first and p.second to second. Returns: *this.
template<class U1, class U2> constexpr pair& operator=(const pair<U1, U2>& p);
// Constraints:
// — is_assignable_v<T1&, const U1&> is true and
// — is_assignable_v<T2&, const U2&> is true.
// Effects: Assigns p.first to first and p.second to second. Returns: *this.
template<class U1, class U2> constexpr const pair& operator=(const pair<U1, U2>& p) const;
// Constraints:
// — is_assignable_v<const T1&, const U1&> is true, and
// — is_assignable_v<const T2&, const U2&> is true.
// Effects: Assigns p.first to first and p.second to second. Returns: *this.
constexpr pair& operator=(pair&& p) noexcept(see_below);
// Constraints:
// — is_move_assignable_v<T1> is true and
// — is_move_assignable_v<T2> is true.
// Effects: Assigns to first with std::forward<T1>(p.first) and to second with std::forward<T2>(
p.second).
// Returns: *this.
// Remarks: The exception specification is equivalent to:
is_nothrow_move_assignable_v<T1> && is_nothrow_move_assignable_v<T2>
constexpr const pair& operator=(pair&& p) const;
// Constraints:
// — is_assignable_v<const T1&, T1> is true and — is_assignable_v<const T2&, T2> is true.
// Effects: Assigns std::forward<T1>(p.first) to first and std::forward<T2>(p.second) to second. Returns: *this.
template<class U1, class U2> constexpr pair& operator=(pair<U1, U2>&& p);
// Constraints:
// — is_assignable_v<T1&, U1> is true and — is_assignable_v<T2&, U2> is true.
// Effects: Assigns to first with std::forward<U1>(p.first) and to second with std::forward<U2>(p.second).
// Returns: *this.
template<class U1, class U2> constexpr const pair& operator=(pair<U1, U2>&& p) const;
// Constraints:
// — is_assignable_v<const T1&, U1> is true, and — is_assignable_v<const T2&, U2> is true.
//Effects: Assigns std::forward<U1>(p.first) to first and std::forward<U2>(u.second) to second. Returns: *this.
constexpr void swap(pair& p) noexcept(see_below);
constexpr void swap(const pair& p) const noexcept(see_below);
// Mandates:
// — For the first overload, is_swappable_v<T1> is true and is_swappable_v<T2> is true.
// — For the second overload, is_swappable_v<const T1> is true and is_swappable_v<const T2> is true.
// Preconditions: first is swappable with (16.4.4.3) p.first and second is swappable with p.second. Effects: Swaps first with p.first and second with p.second.
// Remarks: The exception specification is equivalent to: is_nothrow_swappable_v<T1> && is_nothrow_swappable_v<T2> for the first overload, and is_nothrow_swappable_v<const T1> && is_nothrow_swappable_v<const T2> for the second overload.
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}

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

bash
$ clang++ p670.cpp -std=03 -o p670l -I. -Wall
In file included from p670.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 \
 ^
p670.cpp:30:15: error: redefinition of 'pair'
       struct pair {
              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:211:12: note: previous definition is here
    struct pair
           ^
p670.cpp:74:10: error: C++ requires a type specifier for all declarations
         pair(T1, T2) -> pair<T1, T2>;
         ^
p670.cpp:74:22: error: expected ';' at end of declaration
         pair(T1, T2) -> pair<T1, T2>;
                     ^
                     ;
p670.cpp:74:23: error: cannot use arrow operator on a type
         pair(T1, T2) -> pair<T1, T2>;
                      ^
p670.cpp:80:1: error: unknown type name 'constexpr'
constexpr explicit(see below) pair(); 
^
p670.cpp:80:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see below) pair(); 
                  ^
p670.cpp:80:20: error: use of undeclared identifier 'see'
constexpr explicit(see below) pair(); 
                   ^
p670.cpp:83:1: error: unexpected character <U+2014>
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
^~
p670.cpp:83:32: error: use of undeclared identifier 'T2'
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
                             ^
p670.cpp:83:38: error: expected ';' after top level declarator
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
                                   ^
                                   ;
p670.cpp:91:3: error: expected unqualified-id
  !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
  ^
p670.cpp:98:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                             ^
p670.cpp:98:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                               ^
p670.cpp:98:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                                ~~~~~~~~~^
p670.cpp:99:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                             ^
p670.cpp:99:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                               ^
p670.cpp:99:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                                ~~~~~~~~~^
p670.cpp:100:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                             ^
p670.cpp:100:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                               ^
p670.cpp:100:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                ~~~~~~~~~^
p670.cpp:100:77: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                                            ^
p670.cpp:101:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                             ^
p670.cpp:101:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                                               ^
p670.cpp:101:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                                                ~~~~~~~~~^
p670.cpp:101:83: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                                                                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
7 warnings and 20 errors generated.
$ clang++ p670.cpp -std=2b -o p670l -I. -Wall
p670.cpp:30:15: error: redefinition of 'pair'
       struct pair {
              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:211:12: note: previous definition is here
    struct pair
           ^
p670.cpp:74:10: error: redeclaration of deduction guide
         pair(T1, T2) -> pair<T1, T2>;
         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:460:40: note: previous declaration is here
  template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
                                       ^
p670.cpp:80:20: error: use of undeclared identifier 'see'
constexpr explicit(see below) pair(); 
                   ^
p670.cpp:80:31: error: deduction guide must be declared in the same scope as template 'std::pair'
constexpr explicit(see below) pair(); 
                              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
p670.cpp:80:31: error: deduction guide cannot be declared 'constexpr'
constexpr explicit(see below) pair(); 
~~~~~~~~~                     ^
p670.cpp:80:31: error: deduction guide declaration without trailing return type
p670.cpp:83:1: error: unexpected character <U+2014>
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
^~
p670.cpp:83:32: error: use of undeclared identifier 'T2'
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
                             ^
p670.cpp:91:3: error: expected unqualified-id
  !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
  ^
p670.cpp:98:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                                ~~~~~~~~~^
p670.cpp:98:60: error: deduction guide must be declared in the same scope as template 'std::pair'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
p670.cpp:98:60: error: deduction guide cannot be declared 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                             ~~~~~~~~~                     ^
p670.cpp:98:60: error: deduction guide declaration without trailing return type
p670.cpp:99:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                                ~~~~~~~~~^
p670.cpp:99:60: error: deduction guide must be declared in the same scope as template 'std::pair'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
p670.cpp:99:60: error: deduction guide cannot be declared 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                             ~~~~~~~~~                     ^
p670.cpp:99:60: error: deduction guide declaration without trailing return type
p670.cpp:100:58: error: expected '(' for function-style cast or type construction
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                ~~~~~~~~~^
p670.cpp:100:60: error: deduction guide must be declared in the same scope as template 'std::pair'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p670.cpp -std=03 -o p670g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from p670.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 \
      |  ^~~~~
p670.cpp:37:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   37 | constexpr explicit(see_below) pair();
      | ^~~~~~~~~
p670.cpp:65:37: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   65 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                                     ^~~~~~~~
p670.cpp:83:1: error: extended character — is not valid in an identifier
   83 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:107:19: warning: identifier 'decltype' is a keyword in C++11 [-Wc++11-compat]
  107 | !is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
      |                   ^~~~~~~~
p670.cpp:30:15: error: redefinition of 'struct std::pair<_T1, _T2>'
   30 |        struct pair {
      |               ^~~~
In file included from /usr/local/include/c++/12.1.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/12.1.0/string:50,
                 from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
                 from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
                 from /usr/local/include/c++/12.1.0/ios:42,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from p670.cpp:10:
/usr/local/include/c++/12.1.0/bits/stl_pair.h:185:12: note: previous definition of 'struct std::pair<_T1, _T2>'
  185 |     struct pair
      |            ^~~~
p670.cpp:74:38: error: expected constructor, destructor, or type conversion before ';' token
   74 |          pair(T1, T2) -> pair<T1, T2>;
      |                                      ^
p670.cpp:80:1: error: 'constexpr' does not name a type
   80 | constexpr explicit(see below) pair();
      | ^~~~~~~~~
p670.cpp:80:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:83:1: error: '\U00002014' does not name a type
   83 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:91:3: error: expected unqualified-id before '!' token
   91 |   !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
      |   ^
p670.cpp:98:30: error: 'constexpr' does not name a type
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:98:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:99:30: error: 'constexpr' does not name a type
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:99:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:100:30: error: 'constexpr' does not name a type
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:100:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:101:30: error: 'constexpr' does not name a type
  101 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:101:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:107:1: error: expected unqualified-id before '!' token
  107 | !is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
      | ^
p670.cpp:116:1: error: 'constexpr' does not name a type
  116 | constexpr const pair& operator=(const pair& p) const;
      | ^~~~~~~~~
p670.cpp:116:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:120:30: error: 'constexpr' does not name a type
  120 | template<class U1, class U2> constexpr pair& operator=(const pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:120:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:125:30: error: 'constexpr' does not name a type
  125 | template<class U1, class U2> constexpr const pair& operator=(const pair<U1, U2>& p) const;
      |                              ^~~~~~~~~
p670.cpp:125:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:130:1: error: 'constexpr' does not name a type
  130 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      | ^~~~~~~~~
p670.cpp:130:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:135:1: error: 'p' does not name a type
  135 | p.second).
      | ^
p670.cpp:143:30: error: 'constexpr' does not name a type
  143 | template<class U1, class U2> constexpr pair& operator=(pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:143:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:148:30: error: 'constexpr' does not name a type
  148 | template<class U1, class U2> constexpr const pair& operator=(pair<U1, U2>&& p) const;
      |                              ^~~~~~~~~
p670.cpp:148:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:152:1: error: 'constexpr' does not name a type
  152 | constexpr void swap(pair& p) noexcept(see_below);
      | ^~~~~~~~~
p670.cpp:152:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:153:1: error: 'constexpr' does not name a type
  153 | constexpr void swap(const pair& p) const noexcept(see_below);
      | ^~~~~~~~~
p670.cpp:153:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'

$ g++ p670.cpp -std=2b -o p670g -I. -Wall
p670.cpp:83:1: error: extended character — is not valid in an identifier
   83 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:30:15: error: redefinition of 'struct std::pair<_T1, _T2>'
   30 |        struct pair {
      |               ^~~~
In file included from /usr/local/include/c++/12.1.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/12.1.0/string:50,
                 from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
                 from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
                 from /usr/local/include/c++/12.1.0/ios:42,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from p670.cpp:10:
/usr/local/include/c++/12.1.0/bits/stl_pair.h:185:12: note: previous definition of 'struct std::pair<_T1, _T2>'
  185 |     struct pair
      |            ^~~~
p670.cpp:74:10: error: deduction guide 'template<class T1, class T2> std::pair(T1, T2)-> pair<_T1, _T2>' redeclared
   74 |          pair(T1, T2) -> pair<T1, T2>;
      |          ^~~~
/usr/local/include/c++/12.1.0/bits/stl_pair.h:634:40: note: 'template<class _T1, class _T2> std::pair(_T1, _T2)-> pair<_T1, _T2>' previously declared here
  634 |   template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
      |                                        ^~~~
p670.cpp:80:20: error: 'see' was not declared in this scope
   80 | constexpr explicit(see below) pair();
      |                    ^~~
p670.cpp:80:23: error: expected ')' before 'below'
   80 | constexpr explicit(see below) pair();
      |                   ~   ^~~~~~
      |                       )
p670.cpp:80:24: error: 'below' does not name a type
   80 | constexpr explicit(see below) pair();
      |                        ^~~~~
p670.cpp:83:1: error: '\U00002014' does not name a type
   83 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:91:3: error: expected unqualified-id before '!' token
   91 |   !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
      |   ^
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:98:49: note: in expansion of macro 'see_below'
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                                                 ^~~~~~~~~
p670.cpp:98:49: error: expected ')' before 'int'
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                                                ~^
      |                                                 )
p670.cpp:98:58: error: expected unqualified-id before ')' token
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                                                          ^
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:99:49: note: in expansion of macro 'see_below'
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                                                 ^~~~~~~~~
p670.cpp:99:49: error: expected ')' before 'int'
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                                                ~^
      |                                                 )
p670.cpp:99:58: error: expected unqualified-id before ')' token
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                                                          ^
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:100:49: note: in expansion of macro 'see_below'
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                                                 ^~~~~~~~~
p670.cpp:100:49: error: expected ')' before 'int'
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                                                ~^
      |                                                 )
p670.cpp:100:58: error: expected unqualified-id before ')' token
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                                                          ^
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:101:49: note: in expansion of macro 'see_below'
  101 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                                                 ^~~~~~~~~
p670.cpp:101:49: error: expected ')' before 'int'
  101 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                                                ~^
      |                                                 )
p670.cpp:101:58: error: expected unqualified-id before ')' token
  101 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                                                          ^
p670.cpp:107:1: error: expected unqualified-id before '!' token
  107 | !is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
      | ^
p670.cpp:116:33: error: template placeholder type 'const pair<...auto...>' must be followed by a simple declarator-id
  116 | constexpr const pair& operator=(const pair& p) const;
      |                                 ^~~~~
In file included from /usr/local/include/c++/12.1.0/string:47:
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:116:11: error: deduced class type 'pair' in function return type
  116 | constexpr const pair& operator=(const pair& p) const;
      |           ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:120:40: error: deduced class type 'pair' in function return type
  120 | template<class U1, class U2> constexpr pair& operator=(const pair<U1, U2>& p);
      |                                        ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:125:40: error: deduced class type 'pair' in function return type
  125 | template<class U1, class U2> constexpr const pair& operator=(const pair<U1, U2>& p) const;
      |                                        ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:130:27: error: template placeholder type 'pair<...auto...>' must be followed by a simple declarator-id
  130 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                           ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:130:46: note: in expansion of macro 'see_below'
  130 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                                              ^~~~~~~~~
p670.cpp:130:46: error: expected ')' before 'int'
  130 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                                             ~^
      |                                              )
p670.cpp:26:19: error: expected initializer before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:130:46: note: in expansion of macro 'see_below'
  130 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                                              ^~~~~~~~~
p670.cpp:135:1: error: 'p' does not name a type
  135 | p.second).
      | ^
p670.cpp:143:40: error: deduced class type 'pair' in function return type
  143 | template<class U1, class U2> constexpr pair& operator=(pair<U1, U2>&& p);
      |                                        ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:148:40: error: deduced class type 'pair' in function return type
  148 | template<class U1, class U2> constexpr const pair& operator=(pair<U1, U2>&& p) const;
      |                                        ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:152:21: error: template placeholder type 'pair<...auto...>' must be followed by a simple declarator-id
  152 | constexpr void swap(pair& p) noexcept(see_below);
      |                     ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:152:39: note: in expansion of macro 'see_below'
  152 | constexpr void swap(pair& p) noexcept(see_below);
      |                                       ^~~~~~~~~
p670.cpp:152:39: error: expected ')' before 'int'
  152 | constexpr void swap(pair& p) noexcept(see_below);
      |                                      ~^
      |                                       )
p670.cpp:26:19: error: expected initializer before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:152:39: note: in expansion of macro 'see_below'
  152 | constexpr void swap(pair& p) noexcept(see_below);
      |                                       ^~~~~~~~~
p670.cpp:153:21: error: template placeholder type 'const pair<...auto...>' must be followed by a simple declarator-id
  153 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                     ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:26:19: error: expected primary-expression before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:153:51: note: in expansion of macro 'see_below'
  153 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                                                   ^~~~~~~~~
p670.cpp:153:51: error: expected ')' before 'int'
  153 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                                                  ~^
      |                                                   )
p670.cpp:26:19: error: expected initializer before 'int'
   26 | #define see_below int
      |                   ^~~
p670.cpp:153:51: note: in expansion of macro 'see_below'
  153 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                                                   ^~~~~~~~~
root@8d37178807ec:/home/n4910# vi p670.cpp
root@8d37178807ec:/home/n4910# ./clgc.sh p670
$ clang++ p670.cpp -std=03 -o p670l -I. -Wall
In file included from p670.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 \
 ^
p670.cpp:29:15: error: redefinition of 'pair'
       struct pair {
              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:211:12: note: previous definition is here
    struct pair
           ^
p670.cpp:73:10: error: C++ requires a type specifier for all declarations
         pair(T1, T2) -> pair<T1, T2>;
         ^
p670.cpp:73:22: error: expected ';' at end of declaration
         pair(T1, T2) -> pair<T1, T2>;
                     ^
                     ;
p670.cpp:73:23: error: cannot use arrow operator on a type
         pair(T1, T2) -> pair<T1, T2>;
                      ^
p670.cpp:79:1: error: unknown type name 'constexpr'
constexpr explicit(see below) pair(); 
^
p670.cpp:79:19: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
constexpr explicit(see below) pair(); 
                  ^
p670.cpp:79:20: error: use of undeclared identifier 'see'
constexpr explicit(see below) pair(); 
                   ^
p670.cpp:82:1: error: unexpected character <U+2014>
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
^~
p670.cpp:82:32: error: use of undeclared identifier 'T2'
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
                             ^
p670.cpp:82:38: error: expected ';' after top level declarator
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
                                   ^
                                   ;
p670.cpp:90:3: error: expected unqualified-id
  !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
  ^
p670.cpp:97:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                             ^
p670.cpp:97:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                               ^
p670.cpp:97:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                                ^
p670.cpp:98:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                             ^
p670.cpp:98:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                               ^
p670.cpp:98:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                                ^
p670.cpp:99:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                             ^
p670.cpp:99:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                               ^
p670.cpp:99:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                ^
p670.cpp:99:77: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                                            ^
p670.cpp:100:30: error: unknown type name 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                             ^
p670.cpp:100:48: warning: explicit(bool) is a C++20 extension [-Wc++20-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                                               ^
p670.cpp:100:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                                                ^
p670.cpp:100:83: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
                                                                                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
7 warnings and 20 errors generated.
$ clang++ p670.cpp -std=2b -o p670l -I. -Wall
p670.cpp:29:15: error: redefinition of 'pair'
       struct pair {
              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:211:12: note: previous definition is here
    struct pair
           ^
p670.cpp:73:10: error: redeclaration of deduction guide
         pair(T1, T2) -> pair<T1, T2>;
         ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_pair.h:460:40: note: previous declaration is here
  template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
                                       ^
p670.cpp:79:20: error: use of undeclared identifier 'see'
constexpr explicit(see below) pair(); 
                   ^
p670.cpp:79:31: error: deduction guide must be declared in the same scope as template 'std::pair'
constexpr explicit(see below) pair(); 
                              ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
p670.cpp:79:31: error: deduction guide cannot be declared 'constexpr'
constexpr explicit(see below) pair(); 
~~~~~~~~~                     ^
p670.cpp:79:31: error: deduction guide declaration without trailing return type
p670.cpp:82:1: error: unexpected character <U+2014>
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
^~
p670.cpp:82:32: error: use of undeclared identifier 'T2'
— is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
                             ^
p670.cpp:90:3: error: expected unqualified-id
  !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
  ^
p670.cpp:97:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                                ^
p670.cpp:97:60: error: deduction guide must be declared in the same scope as template 'std::pair'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                                                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
p670.cpp:97:60: error: deduction guide cannot be declared 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p); 
                             ~~~~~~~~~                     ^
p670.cpp:97:60: error: deduction guide declaration without trailing return type
p670.cpp:98:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                                ^
p670.cpp:98:60: error: deduction guide must be declared in the same scope as template 'std::pair'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                                                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
p670.cpp:98:60: error: deduction guide cannot be declared 'constexpr'
template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p); 
                             ~~~~~~~~~                     ^
p670.cpp:98:60: error: deduction guide declaration without trailing return type
p670.cpp:99:49: error: use of undeclared identifier 'see_below'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                ^
p670.cpp:99:60: error: deduction guide must be declared in the same scope as template 'std::pair'
template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p); 
                                                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_iterator.h:2222:12: note: template is declared here
    struct pair;
           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p670.cpp -std=03 -o p670g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from p670.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 \
      |  ^~~~~
p670.cpp:36:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
   36 | constexpr explicit(see_below) pair();
      | ^~~~~~~~~
p670.cpp:64:37: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
   64 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                                     ^~~~~~~~
p670.cpp:82:1: error: extended character — is not valid in an identifier
   82 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:106:19: warning: identifier 'decltype' is a keyword in C++11 [-Wc++11-compat]
  106 | !is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
      |                   ^~~~~~~~
p670.cpp:29:15: error: redefinition of 'struct std::pair<_T1, _T2>'
   29 |        struct pair {
      |               ^~~~
In file included from /usr/local/include/c++/12.1.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/12.1.0/string:50,
                 from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
                 from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
                 from /usr/local/include/c++/12.1.0/ios:42,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from p670.cpp:10:
/usr/local/include/c++/12.1.0/bits/stl_pair.h:185:12: note: previous definition of 'struct std::pair<_T1, _T2>'
  185 |     struct pair
      |            ^~~~
p670.cpp:73:38: error: expected constructor, destructor, or type conversion before ';' token
   73 |          pair(T1, T2) -> pair<T1, T2>;
      |                                      ^
p670.cpp:79:1: error: 'constexpr' does not name a type
   79 | constexpr explicit(see below) pair();
      | ^~~~~~~~~
p670.cpp:79:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:82:1: error: '\U00002014' does not name a type
   82 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:90:3: error: expected unqualified-id before '!' token
   90 |   !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
      |   ^
p670.cpp:97:30: error: 'constexpr' does not name a type
   97 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:97:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:98:30: error: 'constexpr' does not name a type
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:98:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:99:30: error: 'constexpr' does not name a type
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:99:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:100:30: error: 'constexpr' does not name a type
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:100:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:106:1: error: expected unqualified-id before '!' token
  106 | !is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
      | ^
p670.cpp:115:1: error: 'constexpr' does not name a type
  115 | constexpr const pair& operator=(const pair& p) const;
      | ^~~~~~~~~
p670.cpp:115:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:119:30: error: 'constexpr' does not name a type
  119 | template<class U1, class U2> constexpr pair& operator=(const pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:119:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:124:30: error: 'constexpr' does not name a type
  124 | template<class U1, class U2> constexpr const pair& operator=(const pair<U1, U2>& p) const;
      |                              ^~~~~~~~~
p670.cpp:124:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:129:1: error: 'constexpr' does not name a type
  129 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      | ^~~~~~~~~
p670.cpp:129:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:134:1: error: 'p' does not name a type
  134 | p.second).
      | ^
p670.cpp:142:30: error: 'constexpr' does not name a type
  142 | template<class U1, class U2> constexpr pair& operator=(pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:142:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:147:30: error: 'constexpr' does not name a type
  147 | template<class U1, class U2> constexpr const pair& operator=(pair<U1, U2>&& p) const;
      |                              ^~~~~~~~~
p670.cpp:147:30: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:151:1: error: 'constexpr' does not name a type
  151 | constexpr void swap(pair& p) noexcept(see_below);
      | ^~~~~~~~~
p670.cpp:151:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p670.cpp:152:1: error: 'constexpr' does not name a type
  152 | constexpr void swap(const pair& p) const noexcept(see_below);
      | ^~~~~~~~~
p670.cpp:152:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'

$ g++ p670.cpp -std=2b -o p670g -I. -Wall
p670.cpp:82:1: error: extended character — is not valid in an identifier
   82 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:29:15: error: redefinition of 'struct std::pair<_T1, _T2>'
   29 |        struct pair {
      |               ^~~~
In file included from /usr/local/include/c++/12.1.0/bits/stl_algobase.h:64,
                 from /usr/local/include/c++/12.1.0/string:50,
                 from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
                 from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
                 from /usr/local/include/c++/12.1.0/ios:42,
                 from /usr/local/include/c++/12.1.0/ostream:38,
                 from /usr/local/include/c++/12.1.0/iostream:39,
                 from p670.cpp:10:
/usr/local/include/c++/12.1.0/bits/stl_pair.h:185:12: note: previous definition of 'struct std::pair<_T1, _T2>'
  185 |     struct pair
      |            ^~~~
p670.cpp:73:10: error: deduction guide 'template<class T1, class T2> std::pair(T1, T2)-> pair<_T1, _T2>' redeclared
   73 |          pair(T1, T2) -> pair<T1, T2>;
      |          ^~~~
/usr/local/include/c++/12.1.0/bits/stl_pair.h:634:40: note: 'template<class _T1, class _T2> std::pair(_T1, _T2)-> pair<_T1, _T2>' previously declared here
  634 |   template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
      |                                        ^~~~
p670.cpp:79:20: error: 'see' was not declared in this scope
   79 | constexpr explicit(see below) pair();
      |                    ^~~
p670.cpp:79:23: error: expected ')' before 'below'
   79 | constexpr explicit(see below) pair();
      |                   ~   ^~~~~~
      |                       )
p670.cpp:79:24: error: 'below' does not name a type
   79 | constexpr explicit(see below) pair();
      |                        ^~~~~
p670.cpp:82:1: error: '\U00002014' does not name a type
   82 | — is_default_constructible_v<T2> is true. Effects: Value-initializes first // and second.
      | ^
p670.cpp:90:3: error: expected unqualified-id before '!' token
   90 |   !is_convertible_v<U1, T1> || !is_convertible_v<U2, T2>
      |   ^
p670.cpp:97:49: error: 'see_below' was not declared in this scope
   97 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                                                 ^~~~~~~~~
p670.cpp:97:30: error: 'decl-specifier' in declaration of deduction guide
   97 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:97:60: error: deduction guide for 'std::pair<_T1, _T2>' must have trailing return type
   97 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>& p);
      |                                                            ^~~~
In file included from /usr/local/include/c++/12.1.0/string:47:
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:98:49: error: 'see_below' was not declared in this scope
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                                                 ^~~~~~~~~
p670.cpp:98:30: error: 'decl-specifier' in declaration of deduction guide
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                              ^~~~~~~~~
p670.cpp:98:60: error: deduction guide for 'std::pair<_T1, _T2>' must have trailing return type
   98 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>& p);
      |                                                            ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:99:49: error: 'see_below' was not declared in this scope
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                                                 ^~~~~~~~~
p670.cpp:99:30: error: 'decl-specifier' in declaration of deduction guide
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:99:60: error: deduction guide for 'std::pair<_T1, _T2>' must have trailing return type
   99 | template<class U1, class U2> constexpr explicit(see_below) pair(pair<U1, U2>&& p);
      |                                                            ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:100:49: error: 'see_below' was not declared in this scope
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                                                 ^~~~~~~~~
p670.cpp:100:30: error: 'decl-specifier' in declaration of deduction guide
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                              ^~~~~~~~~
p670.cpp:100:60: error: deduction guide for 'std::pair<_T1, _T2>' must have trailing return type
  100 | template<class U1, class U2> constexpr explicit(see_below) pair(const pair<U1, U2>&& p);
      |                                                            ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:106:1: error: expected unqualified-id before '!' token
  106 | !is_convertible_v<decltype(get<0>(FWD(p))), T1> || !is_convertible_v<decltype(get<1>(FWD(p))), T2>
      | ^
p670.cpp:115:33: error: template placeholder type 'const pair<...auto...>' must be followed by a simple declarator-id
  115 | constexpr const pair& operator=(const pair& p) const;
      |                                 ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:115:11: error: deduced class type 'pair' in function return type
  115 | constexpr const pair& operator=(const pair& p) const;
      |           ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:119:40: error: deduced class type 'pair' in function return type
  119 | template<class U1, class U2> constexpr pair& operator=(const pair<U1, U2>& p);
      |                                        ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:124:40: error: deduced class type 'pair' in function return type
  124 | template<class U1, class U2> constexpr const pair& operator=(const pair<U1, U2>& p) const;
      |                                        ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:129:27: error: template placeholder type 'pair<...auto...>' must be followed by a simple declarator-id
  129 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                           ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:129:46: error: 'see_below' was not declared in this scope
  129 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |                                              ^~~~~~~~~
p670.cpp:129:11: error: deduced class type 'pair' in function return type
  129 | constexpr pair& operator=(pair&& p) noexcept(see_below);
      |           ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:134:1: error: 'p' does not name a type
  134 | p.second).
      | ^
p670.cpp:142:40: error: deduced class type 'pair' in function return type
  142 | template<class U1, class U2> constexpr pair& operator=(pair<U1, U2>&& p);
      |                                        ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:147:40: error: deduced class type 'pair' in function return type
  147 | template<class U1, class U2> constexpr const pair& operator=(pair<U1, U2>&& p) const;
      |                                        ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:151:21: error: template placeholder type 'pair<...auto...>' must be followed by a simple declarator-id
  151 | constexpr void swap(pair& p) noexcept(see_below);
      |                     ^~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:151:39: error: 'see_below' was not declared in this scope
  151 | constexpr void swap(pair& p) noexcept(see_below);
      |                                       ^~~~~~~~~
p670.cpp:152:21: error: template placeholder type 'const pair<...auto...>' must be followed by a simple declarator-id
  152 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                     ^~~~~
/usr/local/include/c++/12.1.0/bits/stl_iterator.h:2547:12: note: 'template<class _T1, class _T2> struct std::pair' declared here
 2547 |     struct pair;
      |            ^~~~
p670.cpp:152:51: error: 'see_below' was not declared in this scope
  152 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                                                   ^~~~~~~~~
p670.cpp:152:60: error: non-member function 'constexpr void swap(...)' cannot have cv-qualifier
  152 | constexpr void swap(const pair& p) const noexcept(see_below);
      |                                                            ^

検討事項(agenda)

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

参考資料(reference)

cpprefjp - C++日本語リファレンス

コンパイラの実装状況

typedef は C++11 ではオワコン

C99からC++14を駆け抜けるC++講座

@kazuo_reve 私が効果を確認した「小川メソッド」

自己参照(self reference)

ockerにclang

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

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

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

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

コピペコンパイルエラーあるある

C++ Error Message Collection(1)does not name a type, 11 articles

dockerにclang

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

コンパイル用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

DoCAP(ドゥーキャップ)って何ですか?

小川メソッド 覚え(書きかけ)

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

文書履歴(document history)

ver. 0.01 初稿  20220723

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?