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.

13.10.3.6 Deducing template arguments from a type [temp.deduct.type] C++N4910:2022 (242) p431.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.

13.10.3.6 Deducing template arguments from a type [temp.deduct.type] C++N4910:2022 (242) p431.cpp

算譜(source code)

p431.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 = "13.10.3.6 Deducing template arguments from a type [temp.deduct.type]  C++N4910:2022 (242) p431.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 <typeinfo>

using namespace std;

// Example 1
template<class T> void g(T);
g({1,2,3}); // error: no argument deduced for T
//  [Example 3: Here is an example in which different parameter/argument pairs produce inconsistent template argument deductions:
template<class T> void f(T x, T y) { /* ... */ }
struct A { /* ... */
};
struct B : A { /* ... */
};
void g(A a, B b) {
    f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
    f(b,b); // OK, T is B
}
// Here is an example where two template arguments are deduced from a single function parameter/argument pair. This can lead to conflicts that cause type deduction to fail:
template <class T, class U> void f(  T (*)( T, U, U )  );
int g1( int, float, float);
char g2( int, float, float);
int g3( int, char, float);
void r() {
    f(g1); // OK, T is int and U is float
    f(g2); // error: T deduced as both char and int
    f(g3); // error: U deduced as both char and float
}
Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
template<class T> void f(const T*) { }
int* p;
void s() {
    f(p); // f(const int*)
}
Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
template <class T> struct B { };
template <class T> struct D : public B<T> {};
struct D2 : public B<int> {};
template <class T> void f(B<T>&) {}
void t() {
}
D<int> d;
D2     d2;
f(d);
f(d2);
// calls f(B<int>&) // calls f(B<int>&)
T
cv T
T*
T&
T&& T[integer-constant ]
template-name<T> type (T)
T()
T(T)
(where template-name refers to a class template)
T type::*
type T::*
T T::*
T (type::*)() type (T::*)() type (type ::*)(T) type (T::*)(T)
T (type::*)(T) T (T::*)()
T (T::*)(T) type [i] template-name<i> TT<T>
TT<i> TT<>
// [Example 4:
template<class T1, class... Z> class S;
template<class T1, class... Z> class S<T1, const Z&...> { };
// #1 // #2 // #3
template<class T1, class T2>
S<int, const int&> s;
template<class T, class... U>
template<class T1, class T2, class... U> struct A<T1, T2*, U...> { };
template<class T1, class T2> struct A<T1, T2> { };
template struct A<int, int*>; // selects #2
class S<T1, const T2&> { };
// both #2 and #3 match; #3 is more specialized
struct A { };
// #1 // #2 // #3
// [Example 5:
template <class T> void f(T&&);
template <> void f(int&) { }
template <> void f(int&&) { }
void g(int i) {
    f(i);
    f(0);
// #1 // #2
// cal ls f<int&>(int&), i.e., #1 // cal ls f<int>(int&&), i.e., #2
}
// [Example 7:
X<int> (*)(char[6])
// is of the form
template-name<T> (*)(type[i]) which is a variant of
type (*)(T)
// where type is X<int> and T is char[6].
// [Example 6:
template<class T, class... U> void f(T*, U...) { } // #1 template<class T> void f(T) { } // #2 template void f(int*); // selects #1
template<long n> struct A { };
template<typename T> struct C;
template<typename T, T n> struct C<A<n>> {
    using Q = T;
};
using R = long;
using R = C<A<2>>::Q;
// OK; T was deduced as long from the
// template argument value in the type A<2>
// [Example 9:
template<typename T> struct S;
template<typename T, T n> struct S<int[n]> {
    using Q = T;
};
using V = decltype(sizeof 0);
using V = S<int[42]>::Q;
// [Example 10:
// OK; T was deduced as std::size_t from the type int[42]
template<class T, T i> void f(int (&a)[i]);
int v[10];
void g() {
    f(v); // OK, T is std::size_t
}
// [Note 3: Except for reference and pointer types, a major array bound is not part of a function parameter type and cannot be deduced from an argument:
template<int i> void f1(int a[10][i]);
template<int i> void f2(int a[i][20]);
template<int i> void f3(int (&a)[i][20]);
void g() {
    int v[10][20];
    f1(v); // OK, i deduced as 20
    f1<20>(v); // OK
    f2(v); // error: cannot deduce template-argument i
    f2<10>(v); // OK
    f3(v); // OK, i deduced as 10
}
// [Example 11:
template <int i> class A { /* ... */
};
template <int i> void g(A<i+1>);
template <int i> void f(A<i>, A<i+1>);
void k() {
    A<1> a1;
    A<2> a2;
    g(a1);
    g<0>(a1);
    f(a1, a2);
// error: deduction fails for expression i+1
// OK
// OK
}
//  [Note 5 : Template parameters do not participate in template argument deduction if they are used only in non-deduced contexts. For example,
template<int i, typename T>
T deduce(typename A<T>::X x,
         T t,
         typename B<i>::Y y);
A<int> a;
B<77> b;
// T is not deduced here // but T is deduced here // i is not deduced here
int x = deduce<77>(a.xm, 62, b.ym);
// T deduced as int; a.xm must be convertible to A<int>::X
// i is explicitly specified to be 77; b.ym must be convertible to B<77>::Y
// [Example 12:
template<int i> class A { /* ... */
};
template<short s> void f(A<s>);
void k1() {
    A<1> a;
    f(a); // error: deduction fails for conversion from int to short f<1>(a); // OK
}
template<const short cs> class B { };
template<short s> void g(B<s>);
void k2() {
    B<1> b;
    g(b); // OK, cv-qualifiers are ignored on template parameter types
}
// [Example 13:
template<class T> void f(void(*)(T,int));
template<class T> void foo(T,int);
void g(int,int);
void g(char,int);
void h(int,int,int);
void h(char,int);
int m() {
    f(&g); // error: ambiguous
    f(&h); // OK, void h(char,int) is a unique match
    f(&foo); // error: type deduction fails because foo is a template
}
// [Example 14:
template <class T> void f(T = 5, T = 7);
void g() {
    f(1); // OK, calls f<int>(1,7)
    f(); // error: cannot deduce T
    f<int>(); // OK, calls f<int>(5,7)
}
// [Example 15:
template <template <class T> class X> struct A { };
template <template <class T> class X> void f(A<X>) { }
template<class T> struct B { };
A<B> ab;
f(ab); // calls f(A<B>)
// [Example 16:
template<class> struct X { };
template<class R, class ... ArgTypes> struct X<R(int, ArgTypes ...)> { };
template<class ... Types> struct Y { };
template<class T, class ... Types> struct Y<T, Types& ...> { };
template<class ... Types> int f(void (*)(Types ...));
void g(int, float);
X<int> x1;
X<int(int, float, double)> x2;
X<int(float, int)> x3;
Y<> y1;
Y<int&, float&, double&> y2;
Y<int, float, double> y3;
int fv = f(g);
// uses primary template
// uses partial specialization; ArgTypes contains float, double
// uses primary template
// use primary template; Types is empty
// uses partial specialization; T is int&, Types contains float, double // uses primary template; Types contains int, float, double
// OK; Types contains int, float
int main() {
    cout  <<  n4910 << endl;
    return EXIT_SUCCESS;
}

Script

clgc.sh
#!/bin/sh
rm $1l
rm $1g
echo "$ clang++ $1.cpp -std=03 -o $1l -I. -Wall" 
clang++ $1.cpp -std=c++03 -o $1l -I. -Wall
if [  -e $1l ]; then
./$1l 
fi
rm $1l
echo "$ clang++ $1.cpp -std=2b -o $1l -I. -Wall"
clang++ $1.cpp -std=c++2b -o $1l -I. -Wall
if [  -e $1l ]; then
./$1l
fi
echo "\r"
echo "$ g++ $1.cpp -std=03 -o $1g -I. -Wall"
g++ $1.cpp -std=c++03 -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
rm $1g
echo "\r"
echo "$ g++ $1.cpp -std=2b -o $1g -I. -Wall"
g++ $1.cpp -std=c++2b -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g 
fi

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

bash
# ./clgc.sh p431
rm: cannot remove 'p431l': No such file or directory
rm: cannot remove 'p431g': No such file or directory
$ clang++ p431.cpp -std=c++03 -o p431l -I. -Wall
In file included from p431.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 \
 ^
p431.cpp:27:1: error: C++ requires a type specifier for all declarations
g({1,2,3}); // error: no argument deduced for T
^
p431.cpp:27:3: error: expected expression
g({1,2,3}); // error: no argument deduced for T
  ^
p431.cpp:33:1: error: no matching function for call to 'f'
f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
^
p431.cpp:29:29: note: candidate template ignored: deduced conflicting types for parameter 'T' ('A' vs. 'B')
     template<class T> void f(T x, T y) { /* ... */ }
                            ^
p431.cpp:43:1: error: no matching function for call to 'f'
f(g2); // error: T deduced as both char and int
^
p431.cpp:37:39: note: candidate template ignored: deduced conflicting types for parameter 'T' ('char' vs. 'int')
     template <class T, class U> void f(  T (*)( T, U, U )  );
                                      ^
p431.cpp:29:29: note: candidate function template not viable: requires 2 arguments, but 1 was provided
     template<class T> void f(T x, T y) { /* ... */ }
                            ^
p431.cpp:44:1: error: no matching function for call to 'f'
f(g3); // error: U deduced as both char and float
^
p431.cpp:37:39: note: candidate template ignored: deduced conflicting types for parameter 'U' ('char' vs. 'float')
     template <class T, class U> void f(  T (*)( T, U, U )  );
                                      ^
p431.cpp:29:29: note: candidate function template not viable: requires 2 arguments, but 1 was provided
     template<class T> void f(T x, T y) { /* ... */ }
                            ^
p431.cpp:46:1: error: unknown type name 'Here'
Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
^
p431.cpp:46:8: error: expected ';' after top level declarator
Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
       ^
       ;
p431.cpp:50:3: error: use of undeclared identifier 'p'
f(p); // f(const int*)
  ^
p431.cpp:52:1: error: unknown type name 'Here'
Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
^
p431.cpp:52:8: error: expected ';' after top level declarator
Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
       ^
       ;
p431.cpp:54:40: error: unknown template name 'B'
  template <class T> struct D : public B<T> {};
                                       ^
p431.cpp:55:22: error: unknown template name 'B'
  struct D2 : public B<int> {};
                     ^
p431.cpp:56:30: error: expected ')'
  template <class T> void f(B<T>&) {}
                             ^
p431.cpp:56:28: note: to match this '('
  template <class T> void f(B<T>&) {}
                           ^
p431.cpp:61:1: error: unknown type name 'f'
f(d);
^
p431.cpp:62:1: error: unknown type name 'f'
f(d2);
^
p431.cpp:64:1: error: unknown type name 'T'
T
^
p431.cpp:65:3: error: expected ';' after top level declarator
cv T
  ^
  ;
p431.cpp:82:25: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
template<class T1, class... Z> class S<T1, const Z&...> { };
                        ^
p431.cpp:82:38: error: explicit specialization of undeclared template class 'S'
template<class T1, class... Z> class S<T1, const Z&...> { };
                                     ^~~~~~~~~~~~~~~~~~
p431.cpp:85:22: warning: variable templates are a C++14 extension [-Wc++14-extensions]
  S<int, const int&> s;
                     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
rm: cannot remove 'p431l': No such file or directory
$ clang++ p431.cpp -std=c++2b -o p431l -I. -Wall
p431.cpp:27:1: error: C++ requires a type specifier for all declarations
g({1,2,3}); // error: no argument deduced for T
^
p431.cpp:33:1: error: no matching function for call to 'f'
f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
^
p431.cpp:29:29: note: candidate template ignored: deduced conflicting types for parameter 'T' ('A' vs. 'B')
     template<class T> void f(T x, T y) { /* ... */ }
                            ^
p431.cpp:43:1: error: no matching function for call to 'f'
f(g2); // error: T deduced as both char and int
^
p431.cpp:37:39: note: candidate template ignored: deduced conflicting types for parameter 'T' ('char' vs. 'int')
     template <class T, class U> void f(  T (*)( T, U, U )  );
                                      ^
p431.cpp:29:29: note: candidate function template not viable: requires 2 arguments, but 1 was provided
     template<class T> void f(T x, T y) { /* ... */ }
                            ^
p431.cpp:44:1: error: no matching function for call to 'f'
f(g3); // error: U deduced as both char and float
^
p431.cpp:37:39: note: candidate template ignored: deduced conflicting types for parameter 'U' ('char' vs. 'float')
     template <class T, class U> void f(  T (*)( T, U, U )  );
                                      ^
p431.cpp:29:29: note: candidate function template not viable: requires 2 arguments, but 1 was provided
     template<class T> void f(T x, T y) { /* ... */ }
                            ^
p431.cpp:46:1: error: unknown type name 'Here'
Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
^
p431.cpp:46:8: error: expected ';' after top level declarator
Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
       ^
       ;
p431.cpp:50:3: error: use of undeclared identifier 'p'
f(p); // f(const int*)
  ^
p431.cpp:52:1: error: unknown type name 'Here'
Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
^
p431.cpp:52:8: error: expected ';' after top level declarator
Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
       ^
       ;
p431.cpp:54:40: error: unknown template name 'B'
  template <class T> struct D : public B<T> {};
                                       ^
p431.cpp:55:22: error: unknown template name 'B'
  struct D2 : public B<int> {};
                     ^
p431.cpp:56:30: error: expected ')'
  template <class T> void f(B<T>&) {}
                             ^
p431.cpp:56:28: note: to match this '('
  template <class T> void f(B<T>&) {}
                           ^
p431.cpp:61:1: error: unknown type name 'f'
f(d);
^
p431.cpp:62:1: error: unknown type name 'f'
f(d2);
^
p431.cpp:64:1: error: unknown type name 'T'
T
^
p431.cpp:65:3: error: expected ';' after top level declarator
cv T
  ^
  ;
p431.cpp:82:38: error: explicit specialization of undeclared template class 'S'
template<class T1, class... Z> class S<T1, const Z&...> { };
                                     ^~~~~~~~~~~~~~~~~~
p431.cpp:85:22: error: redefinition of 's' as different kind of symbol
  S<int, const int&> s;
                     ^
p431.cpp:49:6: note: previous definition is here
void s() {
     ^
p431.cpp:87:39: error: declaration of 'U' shadows template parameter
template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
                                      ^
p431.cpp:86:28: note: template parameter is declared here
template<class T, class... U>
                           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

$ g++ p431.cpp -std=c++03 -o p431g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
                 from p431.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 \
      |  ^~~~~
p431.cpp:121:16: warning: identifier 'decltype' is a keyword in C++11 [-Wc++11-compat]
  121 |      using V = decltype(sizeof 0);
      |                ^~~~~~~~
p431.cpp:27:2: error: expected constructor, destructor, or type conversion before '(' token
   27 | g({1,2,3}); // error: no argument deduced for T
      |  ^
p431.cpp:27:10: error: expected unqualified-id before ')' token
   27 | g({1,2,3}); // error: no argument deduced for T
      |          ^
p431.cpp: In function 'void g(A, B)':
p431.cpp:33:2: error: no matching function for call to 'f(A&, B&)'
   33 | f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
      | ~^~~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:33:2: note:   deduced conflicting types for parameter 'T' ('A' and 'B')
   33 | f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
      | ~^~~~~
p431.cpp: In function 'void r()':
p431.cpp:43:2: error: no matching function for call to 'f(char (&)(int, float, float))'
   43 | f(g2); // error: T deduced as both char and int
      | ~^~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:43:2: note:   candidate expects 2 arguments, 1 provided
   43 | f(g2); // error: T deduced as both char and int
      | ~^~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:43:2: note:   deduced conflicting types for parameter 'T' ('char' and 'int')
   43 | f(g2); // error: T deduced as both char and int
      | ~^~~~
p431.cpp:44:2: error: no matching function for call to 'f(int (&)(int, char, float))'
   44 | f(g3); // error: U deduced as both char and float
      | ~^~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:44:2: note:   candidate expects 2 arguments, 1 provided
   44 | f(g3); // error: U deduced as both char and float
      | ~^~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:44:2: note:   deduced conflicting types for parameter 'U' ('char' and 'float')
   44 | f(g3); // error: U deduced as both char and float
      | ~^~~~
p431.cpp: At global scope:
p431.cpp:46:1: error: 'Here' does not name a type
   46 | Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
      | ^~~~
p431.cpp: In function 'void s()':
p431.cpp:50:2: error: no matching function for call to 'f(int*&)'
   50 | f(p); // f(const int*)
      | ~^~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:50:2: note:   candidate expects 2 arguments, 1 provided
   50 | f(p); // f(const int*)
      | ~^~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:50:2: note:   mismatched types 'T(T, U, U)' and 'int'
   50 | f(p); // f(const int*)
      | ~^~~
p431.cpp: At global scope:
p431.cpp:52:1: error: 'Here' does not name a type
   52 | Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
      | ^~~~
p431.cpp:54:41: error: expected template-name before '<' token
   54 |   template <class T> struct D : public B<T> {};
      |                                         ^
p431.cpp:54:41: error: expected '{' before '<' token
p431.cpp:55:23: error: expected template-name before '<' token
   55 |   struct D2 : public B<int> {};
      |                       ^
p431.cpp:55:23: error: expected '{' before '<' token
p431.cpp:55:23: error: expected unqualified-id before '<' token
p431.cpp:56:29: error: 'B' is not a template
   56 |   template <class T> void f(B<T>&) {}
      |                             ^
p431.cpp:59:8: error: aggregate 'D<int> d' has incomplete type and cannot be defined
   59 | D<int> d;
      |        ^
p431.cpp:60:8: error: aggregate 'D2 d2' has incomplete type and cannot be defined
   60 | D2     d2;
      |        ^~
p431.cpp:61:2: error: expected constructor, destructor, or type conversion before '(' token
   61 | f(d);
      |  ^
p431.cpp:62:2: error: expected constructor, destructor, or type conversion before '(' token
   62 | f(d2);
      |  ^
p431.cpp:64:1: error: 'T' does not name a type
   64 | T
      | ^
p431.cpp:82:25: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   82 | template<class T1, class... Z> class S<T1, const Z&...> { };
      |                         ^~~
p431.cpp:82:38: error: 'S' is not a class template
   82 | template<class T1, class... Z> class S<T1, const Z&...> { };
      |                                      ^
p431.cpp:85:22: error: 'template<class T1, class T2> S<int, const int&> s' redeclared as different kind of entity
   85 |   S<int, const int&> s;
      |                      ^
p431.cpp:49:6: note: previous declaration 'void s()'
   49 | void s() {
      |      ^
p431.cpp:86:24: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   86 | template<class T, class... U>
      |                        ^~~
p431.cpp:87:35: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                   ^~~
p431.cpp:87:30: error: declaration of template parameter 'U' shadows template parameter
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                              ^~~~~
p431.cpp:86:19: note: template parameter 'U' declared here
   86 | template<class T, class... U>
      |                   ^~~~~
p431.cpp:87:49: error: 'A' is not a class template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                 ^
p431.cpp:87:49: error: too many template-parameter-lists
p431.cpp:87:107: error: 'A' is not a class template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                                                                           ^
p431.cpp:87:115: error: 'A' is not a template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                                                                                   ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:87:138: error: 'A' is not a class template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                                                                                                          ^
p431.cpp:87:138: error: explicit instantiation of non-template type 'A'
p431.cpp:88:9: error: 'T1' was not declared in this scope; did you mean 'y1'?
   88 | class S<T1, const T2&> { };
      |         ^~
      |         y1
p431.cpp:88:19: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
   88 | class S<T1, const T2&> { };
      |                   ^~
p431.cpp:88:22: error: template argument 1 is invalid
   88 | class S<T1, const T2&> { };
      |                      ^
p431.cpp:88:22: error: template argument 2 is invalid
p431.cpp:88:1: error: an explicit specialization must be preceded by 'template <>'
   88 | class S<T1, const T2&> { };
      | ^~~~~~~~~~~~~~~~~~~~~~
      | template <> 
p431.cpp:90:8: error: redefinition of 'struct A'
   90 | struct A { };
      |        ^
p431.cpp:30:13: note: previous definition of 'struct A'
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:93:30: error: expected ',' or '...' before '&&' token
   93 |   template <class T> void f(T&&);
      |                              ^~
p431.cpp:95:25: error: expected ',' or '...' before '&&' token
   95 |   template <> void f(int&&) { }
      |                         ^~
p431.cpp:102:1: error: 'X' does not name a type
  102 | X<int> (*)(char[6])
      | ^
p431.cpp:109:25: error: 'A' is not a template
  109 | template<long n> struct A { };
      |                         ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:111:36: error: 'A' is not a template
  111 | template<typename T, T n> struct C<A<n>> {
      |                                    ^
p431.cpp:111:39: warning: '>>' operator is treated as two right angle brackets in C++11 [-Wc++11-compat]
  111 | template<typename T, T n> struct C<A<n>> {
      |                                       ^~
p431.cpp:111:39: note: suggest parentheses around '>>' expression
p431.cpp:111:42: warning: extended initializer lists only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  111 | template<typename T, T n> struct C<A<n>> {
      |                                          ^
p431.cpp:111:36: error: template argument 1 is invalid
  111 | template<typename T, T n> struct C<A<n>> {
      |                                    ^
p431.cpp:113:7: error: expected nested-name-specifier before 'R'
  113 | using R = long;
      |       ^
p431.cpp:114:7: error: expected nested-name-specifier before 'R'
  114 | using R = C<A<2>>::Q;
      |       ^
p431.cpp:118:34: error: redeclared with 1 template parameter
  118 |      template<typename T> struct S;
      |                                  ^
p431.cpp:82:55: note: previous declaration 'template<class T1, class ... Z> class S' used 2 template parameters
   82 | template<class T1, class... Z> class S<T1, const Z&...> { };
      |                                                       ^
p431.cpp:119:39: error: template parameters not deducible in partial specialization:
  119 |      template<typename T, T n> struct S<int[n]> {
      |                                       ^~~~~~~~~
p431.cpp:119:39: note:         'T'
p431.cpp:121:12: error: expected nested-name-specifier before 'V'
  121 |      using V = decltype(sizeof 0);
      |            ^
p431.cpp:122:12: error: expected nested-name-specifier before 'V'
  122 |      using V = S<int[42]>::Q;
      |            ^
p431.cpp:134:6: error: redefinition of 'void g()'
  134 | void g() {
      |      ^
p431.cpp:127:11: note: 'void g()' previously defined here
  127 |      void g() {
      |           ^
p431.cpp: In function 'void g()':
p431.cpp:138:3: error: no matching function for call to 'f2(int [10][20])'
  138 | f2(v); // error: cannot deduce template-argument i
      | ~~^~~
p431.cpp:132:27: note: candidate: 'template<int i> void f2(int (*)[20])'
  132 |      template<int i> void f2(int a[i][20]);
      |                           ^~
p431.cpp:132:27: note:   template argument deduction/substitution failed:
p431.cpp:138:3: note:   couldn't deduce template parameter 'i'
  138 | f2(v); // error: cannot deduce template-argument i
      | ~~^~~
p431.cpp: At global scope:
p431.cpp:143:26: error: 'A' is not a template
  143 |   template <int i> class A { /* ... */ };
      |                          ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:144:27: error: 'A' is not a template
  144 |   template <int i> void g(A<i+1>);
      |                           ^
p431.cpp:145:27: error: 'A' is not a template
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                           ^
p431.cpp:145:33: error: 'A' is not a template
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                                 ^
p431.cpp: In function 'void k()':
p431.cpp:147:5: error: 'A' is not a template
  147 |     A<1> a1;
      |     ^
p431.cpp:148:5: error: 'A' is not a template
  148 |     A<2> a2;
      |     ^
p431.cpp: At global scope:
p431.cpp:158:21: error: expected nested-name-specifier before 'A'
  158 |   T deduce(typename A<T>::X x,
      |                     ^
p431.cpp:158:21: error: expected '(' before 'A'
  158 |   T deduce(typename A<T>::X x,
      |                     ^
      |                     (
p431.cpp:159:3: error: expected primary-expression before 't'
  159 | T t,
      |   ^
p431.cpp:160:21: error: expected nested-name-specifier before 'B'
  160 |            typename B<i>::Y y);
      |                     ^
p431.cpp:160:21: error: expected '(' before 'B'
  160 |            typename B<i>::Y y);
      |                     ^
      |                     (
p431.cpp:158:5: warning: variable templates only available with '-std=c++14' or '-std=gnu++14' [-Wc++14-extensions]
  158 |   T deduce(typename A<T>::X x,
      |     ^~~~~~
p431.cpp:161:3: error: 'A' is not a template
  161 |   A<int> a;
      |   ^
p431.cpp:162:1: error: 'B' is not a template
  162 | B<77> b;
      | ^
p431.cpp:164:9: error: wrong number of template arguments (1, should be 2)
  164 | int x = deduce<77>(a.xm, 62, b.ym);
      |         ^~~~~~~~~~
p431.cpp:158:5: note: provided for 'template<int i, class T> T deduce<i, T>'
  158 |   T deduce(typename A<T>::X x,
      |     ^~~~~~
p431.cpp:164:22: error: 'struct A' has no member named 'xm'
  164 | int x = deduce<77>(a.xm, 62, b.ym);
      |                      ^~
p431.cpp:164:32: error: 'struct B' has no member named 'ym'
  164 | int x = deduce<77>(a.xm, 62, b.ym);
      |                                ^~
p431.cpp:168:28: error: 'A' is not a template
  168 |      template<int i> class A { /* ... */ };
      |                            ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:169:31: error: 'A' is not a template
  169 |      template<short s> void f(A<s>);
      |                               ^
p431.cpp: In function 'void k1()':
p431.cpp:171:1: error: 'A' is not a template
  171 | A<1> a;
      | ^
p431.cpp: At global scope:
p431.cpp:174:37: error: 'B' is not a template
  174 |      template<const short cs> class B { };
      |                                     ^
p431.cpp:31:13: note: previous declaration here
   31 |      struct B : A { /* ... */ };
      |             ^
p431.cpp:175:31: error: 'B' is not a template
  175 |      template<short s> void g(B<s>);
      |                               ^
p431.cpp: In function 'void k2()':
p431.cpp:177:1: error: 'B' is not a template
  177 | B<1> b;
      | ^
p431.cpp: In function 'int m()':
p431.cpp:188:2: error: no matching function for call to 'f(<unresolved overloaded function type>)'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'char')
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'int')
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'B')
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'A')
p431.cpp:188:2: note:   candidate expects 3 arguments, 0 provided
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'int')
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'A')
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:93:27: note: candidate: 'template<class T> void f(T)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(char, int)'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(int, int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(B)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(A)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)()'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(A, B)'
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   couldn't deduce template parameter 's'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
p431.cpp:188:2: note:   candidate expects 2 arguments, 0 provided
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
p431.cpp:188:2: note:   mismatched types 'int' and 'B'
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
p431.cpp:190:2: error: no matching function for call to 'f(<unresolved overloaded function type>)'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   candidate expects 2 arguments, 1 provided
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:93:27: note: candidate: 'template<class T> void f(T)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   candidate expects 2 arguments, 1 provided
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 's'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:191:1: warning: no return statement in function returning non-void [-Wreturn-type]
  191 | }
      | ^
p431.cpp: At global scope:
p431.cpp:193:30: error: redeclaration of 'template<class T> void f(T, T)' may not have default arguments [-fpermissive]
  193 |      template <class T> void f(T = 5, T = 7);
      |                              ^
p431.cpp:194:11: error: redefinition of 'void g()'
  194 |      void g() {
      |           ^
p431.cpp:127:11: note: 'void g()' previously defined here
  127 |      void g() {
      |           ^
p431.cpp: In function 'void g()':
p431.cpp:196:2: error: no matching function for call to 'f()'
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 2 arguments, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:93:27: note: candidate: 'template<class T> void f(T)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 2 arguments, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:197:7: error: no matching function for call to 'f<int>()'
  197 | f<int>(); // OK, calls f<int>(5,7)
      | ~~~~~~^~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   candidate expects 2 arguments, 0 provided
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   candidate expects 1 argument, 0 provided
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   candidate expects 1 argument, 0 provided
p431.cpp:93:27: note: candidate: 'template<class T> void f(T)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   candidate expects 1 argument, 0 provided
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   candidate expects 1 argument, 0 provided
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   candidate expects 2 arguments, 0 provided
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   candidate expects 1 argument, 0 provided
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   candidate expects 1 argument, 0 provided
p431.cpp: At global scope:
p431.cpp:200:51: error: 'A' is not a template
  200 |      template <template <class T> class X> struct A { };
      |                                                   ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:201:51: error: 'A' is not a template
  201 |      template <template <class T> class X> void f(A<X>) { }
      |                                                   ^
p431.cpp:202:31: error: 'B' is not a template
  202 |      template<class T> struct B { };
      |                               ^
p431.cpp:31:13: note: previous declaration here
   31 |      struct B : A { /* ... */ };
      |             ^
p431.cpp:203:6: error: 'A' is not a template
  203 |      A<B> ab;
      |      ^
p431.cpp:204:2: error: expected constructor, destructor, or type conversion before '(' token
  204 | f(ab); // calls f(A<B>)
      |  ^
p431.cpp:207:30: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  207 |      template<class R, class ... ArgTypes> struct X<R(int, ArgTypes ...)> { };
      |                              ^~~
p431.cpp:207:69: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  207 |      template<class R, class ... ArgTypes> struct X<R(int, ArgTypes ...)> { };
      |                                                                     ^~~
p431.cpp:208:21: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  208 |      template<class ... Types> struct Y { };
      |                     ^~~
p431.cpp:209:30: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  209 |      template<class T, class ... Types> struct Y<T, Types& ...> { };
      |                              ^~~
p431.cpp:210:21: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  210 |      template<class ... Types> int f(void (*)(Types ...));
      |                     ^~~
p431.cpp:210:53: warning: variadic templates only available with '-std=c++11' or '-std=gnu++11' [-Wc++11-extensions]
  210 |      template<class ... Types> int f(void (*)(Types ...));
      |                                                     ^~~
p431.cpp:215:5: error: 'Y<> y1' redeclared as different kind of entity
  215 | Y<> y1;
      |     ^~
In file included from /usr/include/features.h:461,
                 from /usr/local/include/c++/12.1.0/x86_64-linux-gnu/bits/os_defines.h:39,
                 from /usr/local/include/c++/12.1.0/x86_64-linux-gnu/bits/c++config.h:655,
                 from /usr/local/include/c++/12.1.0/iostream:38,
                 from p431.cpp:10:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration 'double y1(double)'
  221 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
rm: cannot remove 'p431g': No such file or directory

$ g++ p431.cpp -std=c++2b -o p431g -I. -Wall
p431.cpp:27:2: error: expected constructor, destructor, or type conversion before '(' token
   27 | g({1,2,3}); // error: no argument deduced for T
      |  ^
p431.cpp:27:10: error: expected unqualified-id before ')' token
   27 | g({1,2,3}); // error: no argument deduced for T
      |          ^
p431.cpp: In function 'void g(A, B)':
p431.cpp:33:2: error: no matching function for call to 'f(A&, B&)'
   33 | f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
      | ~^~~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:33:2: note:   deduced conflicting types for parameter 'T' ('A' and 'B')
   33 | f(a,b); // error: T deduced as both A and B f(b,a); // error: T deduced as both A and B f(a,a); // OK, T is A
      | ~^~~~~
p431.cpp: In function 'void r()':
p431.cpp:43:2: error: no matching function for call to 'f(char (&)(int, float, float))'
   43 | f(g2); // error: T deduced as both char and int
      | ~^~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:43:2: note:   candidate expects 2 arguments, 1 provided
   43 | f(g2); // error: T deduced as both char and int
      | ~^~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:43:2: note:   deduced conflicting types for parameter 'T' ('char' and 'int')
   43 | f(g2); // error: T deduced as both char and int
      | ~^~~~
p431.cpp:44:2: error: no matching function for call to 'f(int (&)(int, char, float))'
   44 | f(g3); // error: U deduced as both char and float
      | ~^~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:44:2: note:   candidate expects 2 arguments, 1 provided
   44 | f(g3); // error: U deduced as both char and float
      | ~^~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:44:2: note:   deduced conflicting types for parameter 'U' ('char' and 'float')
   44 | f(g3); // error: U deduced as both char and float
      | ~^~~~
p431.cpp: At global scope:
p431.cpp:46:1: error: 'Here' does not name a type
   46 | Here is an example where a qualification conversion applies between the argument type on the function call and the deduced template argument type:
      | ^~~~
p431.cpp: In function 'void s()':
p431.cpp:50:2: error: no matching function for call to 'f(int*&)'
   50 | f(p); // f(const int*)
      | ~^~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:50:2: note:   candidate expects 2 arguments, 1 provided
   50 | f(p); // f(const int*)
      | ~^~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:50:2: note:   mismatched types 'T(T, U, U)' and 'int'
   50 | f(p); // f(const int*)
      | ~^~~
p431.cpp: At global scope:
p431.cpp:52:1: error: 'Here' does not name a type
   52 | Here is an example where the template argument is used to instantiate a derived class type of the corresponding function parameter type:
      | ^~~~
p431.cpp:54:41: error: expected template-name before '<' token
   54 |   template <class T> struct D : public B<T> {};
      |                                         ^
p431.cpp:54:41: error: expected '{' before '<' token
p431.cpp:55:23: error: expected template-name before '<' token
   55 |   struct D2 : public B<int> {};
      |                       ^
p431.cpp:55:23: error: expected '{' before '<' token
p431.cpp:55:23: error: expected unqualified-id before '<' token
p431.cpp:56:29: error: 'B' is not a template
   56 |   template <class T> void f(B<T>&) {}
      |                             ^
p431.cpp:59:8: error: aggregate 'D<int> d' has incomplete type and cannot be defined
   59 | D<int> d;
      |        ^
p431.cpp:60:8: error: aggregate 'D2 d2' has incomplete type and cannot be defined
   60 | D2     d2;
      |        ^~
p431.cpp:61:2: error: expected constructor, destructor, or type conversion before '(' token
   61 | f(d);
      |  ^
p431.cpp:62:2: error: expected constructor, destructor, or type conversion before '(' token
   62 | f(d2);
      |  ^
p431.cpp:64:1: error: 'T' does not name a type
   64 | T
      | ^
p431.cpp:82:38: error: 'S' is not a class template
   82 | template<class T1, class... Z> class S<T1, const Z&...> { };
      |                                      ^
p431.cpp:85:22: error: 'template<class T1, class T2> S<int, const int&> s' redeclared as different kind of entity
   85 |   S<int, const int&> s;
      |                      ^
p431.cpp:49:6: note: previous declaration 'void s()'
   49 | void s() {
      |      ^
p431.cpp:87:30: error: declaration of template parameter 'U' shadows template parameter
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                              ^~~~~
p431.cpp:86:19: note: template parameter 'U' declared here
   86 | template<class T, class... U>
      |                   ^~~~~
p431.cpp:87:49: error: 'A' is not a class template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                 ^
p431.cpp:87:49: error: too many template-parameter-lists
p431.cpp:87:107: error: 'A' is not a class template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                                                                           ^
p431.cpp:87:115: error: 'A' is not a template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                                                                                   ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:87:138: error: 'A' is not a class template
   87 | template<class T1, class T2, class... U> struct A<T1, T2*, U...> { }; template<class T1, class T2> struct A<T1, T2> { }; template struct A<int, int*>; // selects #2
      |                                                                                                                                          ^
p431.cpp:87:138: error: explicit instantiation of non-template type 'A'
p431.cpp:88:9: error: 'T1' was not declared in this scope; did you mean 'y1'?
   88 | class S<T1, const T2&> { };
      |         ^~
      |         y1
p431.cpp:88:19: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
   88 | class S<T1, const T2&> { };
      |                   ^~
p431.cpp:88:22: error: template argument 1 is invalid
   88 | class S<T1, const T2&> { };
      |                      ^
p431.cpp:88:22: error: template argument 2 is invalid
p431.cpp:88:1: error: an explicit specialization must be preceded by 'template <>'
   88 | class S<T1, const T2&> { };
      | ^~~~~~~~~~~~~~~~~~~~~~
      | template <> 
p431.cpp:90:8: error: redefinition of 'struct A'
   90 | struct A { };
      |        ^
p431.cpp:30:13: note: previous definition of 'struct A'
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:102:1: error: specializing member '::X<int>' requires 'template<>' syntax
  102 | X<int> (*)(char[6])
      | ^~~~~~
p431.cpp:109:25: error: 'A' is not a template
  109 | template<long n> struct A { };
      |                         ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:111:36: error: 'A' is not a template
  111 | template<typename T, T n> struct C<A<n>> {
      |                                    ^
p431.cpp:111:34: error: template parameters not deducible in partial specialization:
  111 | template<typename T, T n> struct C<A<n>> {
      |                                  ^~~~~~~
p431.cpp:111:34: note:         'T'
p431.cpp:111:34: note:         'n'
p431.cpp:114:13: error: 'A' is not a template
  114 | using R = C<A<2>>::Q;
      |             ^
p431.cpp:114:20: error: invalid use of incomplete type 'struct C<A>'
  114 | using R = C<A<2>>::Q;
      |                    ^
p431.cpp:111:34: note: declaration of 'struct C<A>'
  111 | template<typename T, T n> struct C<A<n>> {
      |                                  ^~~~~~~
p431.cpp:118:34: error: redeclared with 1 template parameter
  118 |      template<typename T> struct S;
      |                                  ^
p431.cpp:82:55: note: previous declaration 'template<class T1, class ... Z> class S' used 2 template parameters
   82 | template<class T1, class... Z> class S<T1, const Z&...> { };
      |                                                       ^
p431.cpp:134:6: error: redefinition of 'void g()'
  134 | void g() {
      |      ^
p431.cpp:127:11: note: 'void g()' previously defined here
  127 |      void g() {
      |           ^
p431.cpp: In function 'void g()':
p431.cpp:138:3: error: no matching function for call to 'f2(int [10][20])'
  138 | f2(v); // error: cannot deduce template-argument i
      | ~~^~~
p431.cpp:132:27: note: candidate: 'template<int i> void f2(int (*)[20])'
  132 |      template<int i> void f2(int a[i][20]);
      |                           ^~
p431.cpp:132:27: note:   template argument deduction/substitution failed:
p431.cpp:138:3: note:   couldn't deduce template parameter 'i'
  138 | f2(v); // error: cannot deduce template-argument i
      | ~~^~~
p431.cpp: At global scope:
p431.cpp:143:26: error: 'A' is not a template
  143 |   template <int i> class A { /* ... */ };
      |                          ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:144:27: error: 'A' is not a template
  144 |   template <int i> void g(A<i+1>);
      |                           ^
p431.cpp:145:27: error: 'A' is not a template
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                           ^
p431.cpp:145:33: error: 'A' is not a template
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                                 ^
p431.cpp: In function 'void k()':
p431.cpp:147:5: error: 'A' is not a template
  147 |     A<1> a1;
      |     ^
p431.cpp:148:5: error: 'A' is not a template
  148 |     A<2> a2;
      |     ^
p431.cpp: At global scope:
p431.cpp:158:21: error: expected nested-name-specifier before 'A'
  158 |   T deduce(typename A<T>::X x,
      |                     ^
p431.cpp:158:21: error: expected '(' before 'A'
  158 |   T deduce(typename A<T>::X x,
      |                     ^
      |                     (
p431.cpp:159:3: error: expected primary-expression before 't'
  159 | T t,
      |   ^
p431.cpp:160:21: error: expected nested-name-specifier before 'B'
  160 |            typename B<i>::Y y);
      |                     ^
p431.cpp:160:21: error: expected '(' before 'B'
  160 |            typename B<i>::Y y);
      |                     ^
      |                     (
p431.cpp:161:3: error: 'A' is not a template
  161 |   A<int> a;
      |   ^
p431.cpp:162:1: error: 'B' is not a template
  162 | B<77> b;
      | ^
p431.cpp:164:9: error: wrong number of template arguments (1, should be 2)
  164 | int x = deduce<77>(a.xm, 62, b.ym);
      |         ^~~~~~~~~~
p431.cpp:158:5: note: provided for 'template<int i, class T> T deduce<i, T>'
  158 |   T deduce(typename A<T>::X x,
      |     ^~~~~~
p431.cpp:164:22: error: 'struct A' has no member named 'xm'
  164 | int x = deduce<77>(a.xm, 62, b.ym);
      |                      ^~
p431.cpp:164:32: error: 'struct B' has no member named 'ym'
  164 | int x = deduce<77>(a.xm, 62, b.ym);
      |                                ^~
p431.cpp:168:28: error: 'A' is not a template
  168 |      template<int i> class A { /* ... */ };
      |                            ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:169:31: error: 'A' is not a template
  169 |      template<short s> void f(A<s>);
      |                               ^
p431.cpp: In function 'void k1()':
p431.cpp:171:1: error: 'A' is not a template
  171 | A<1> a;
      | ^
p431.cpp: At global scope:
p431.cpp:174:37: error: 'B' is not a template
  174 |      template<const short cs> class B { };
      |                                     ^
p431.cpp:31:13: note: previous declaration here
   31 |      struct B : A { /* ... */ };
      |             ^
p431.cpp:175:31: error: 'B' is not a template
  175 |      template<short s> void g(B<s>);
      |                               ^
p431.cpp: In function 'void k2()':
p431.cpp:177:1: error: 'B' is not a template
  177 | B<1> b;
      | ^
p431.cpp: In function 'int m()':
p431.cpp:188:2: error: no matching function for call to 'f(<unresolved overloaded function type>)'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'char')
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'int')
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'B')
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'A')
p431.cpp:188:2: note:   candidate expects 3 arguments, 0 provided
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'int')
p431.cpp:188:2: note:   deduced conflicting types for parameter 'T' ('void' and 'A')
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:93:27: note: candidate: 'template<class T> void f(T&&)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(char, int)'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(int, int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(B)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(A)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)()'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(A, B)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(char, int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(int, int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(B)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(A)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)()'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(int)'
p431.cpp:188:2: note:   mismatched types 'int [i]' and 'void (*)(A, B)'
p431.cpp:188:2: note:   couldn't deduce template parameter 'i'
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   couldn't deduce template parameter 's'
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   template argument deduction/substitution failed:
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
  188 | f(&g); // error: ambiguous
      | ~^~~~
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
p431.cpp:188:2: note:   candidate expects 2 arguments, 0 provided
p431.cpp:188:2: note:   candidate expects 2 arguments, 1 provided
p431.cpp:188:2: note:   mismatched types 'int' and 'B'
p431.cpp:188:2: note:   couldn't deduce template parameter 'T'
p431.cpp:190:2: error: no matching function for call to 'f(<unresolved overloaded function type>)'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   candidate expects 2 arguments, 1 provided
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:93:27: note: candidate: 'template<class T> void f(T&&)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'i'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   candidate expects 2 arguments, 1 provided
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 's'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   template argument deduction/substitution failed:
p431.cpp:190:2: note:   couldn't deduce template parameter 'T'
  190 | f(&foo); // error: type deduction fails because foo is a template
      | ~^~~~~~
p431.cpp:191:1: warning: no return statement in function returning non-void [-Wreturn-type]
  191 | }
      | ^
p431.cpp: At global scope:
p431.cpp:193:30: error: redeclaration of 'template<class T> void f(T, T)' may not have default arguments [-fpermissive]
  193 |      template <class T> void f(T = 5, T = 7);
      |                              ^
p431.cpp:194:11: error: redefinition of 'void g()'
  194 |      void g() {
      |           ^
p431.cpp:127:11: note: 'void g()' previously defined here
  127 |      void g() {
      |           ^
p431.cpp: In function 'void g()':
p431.cpp:196:2: error: no matching function for call to 'f()'
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 2 arguments, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:93:27: note: candidate: 'template<class T> void f(T&&)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 2 arguments, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   template argument deduction/substitution failed:
p431.cpp:196:2: note:   candidate expects 1 argument, 0 provided
  196 | f(); // error: cannot deduce T
      | ~^~
p431.cpp:197:7: error: no matching function for call to 'f<int>()'
  197 | f<int>(); // OK, calls f<int>(5,7)
      | ~~~~~~^~
p431.cpp:29:29: note: candidate: 'template<class T> void f(T, T)'
   29 |      template<class T> void f(T x, T y) { /* ... */ }
      |                             ^
p431.cpp:29:29: note:   candidate expects 2 arguments, 0 provided
p431.cpp:37:39: note: candidate: 'template<class T, class U> void f(T (*)(T, U, U))'
   37 |      template <class T, class U> void f(  T (*)( T, U, U )  );
      |                                       ^
p431.cpp:37:39: note:   candidate expects 1 argument, 0 provided
p431.cpp:56:27: note: candidate: 'template<class T> void f(B&)'
   56 |   template <class T> void f(B<T>&) {}
      |                           ^
p431.cpp:56:27: note:   candidate expects 1 argument, 0 provided
p431.cpp:93:27: note: candidate: 'template<class T> void f(T&&)'
   93 |   template <class T> void f(T&&);
      |                           ^
p431.cpp:93:27: note:   candidate expects 1 argument, 0 provided
p431.cpp:125:34: note: candidate: 'template<class T, T i> void f(int (&)[i])'
  125 |      template<class T, T i> void f(int (&a)[i]);
      |                                  ^
p431.cpp:125:34: note:   candidate expects 1 argument, 0 provided
p431.cpp:145:25: note: candidate: 'template<int i> void f(A, A)'
  145 |   template <int i> void f(A<i>, A<i+1>);
      |                         ^
p431.cpp:145:25: note:   candidate expects 2 arguments, 0 provided
p431.cpp:169:29: note: candidate: 'template<short int s> void f(A)'
  169 |      template<short s> void f(A<s>);
      |                             ^
p431.cpp:169:29: note:   candidate expects 1 argument, 0 provided
p431.cpp:181:29: note: candidate: 'template<class T> void f(void (*)(T, int))'
  181 |      template<class T> void f(void(*)(T,int));
      |                             ^
p431.cpp:181:29: note:   candidate expects 1 argument, 0 provided
p431.cpp: At global scope:
p431.cpp:200:51: error: 'A' is not a template
  200 |      template <template <class T> class X> struct A { };
      |                                                   ^
p431.cpp:30:13: note: previous declaration here
   30 |      struct A { /* ... */ };
      |             ^
p431.cpp:201:51: error: 'A' is not a template
  201 |      template <template <class T> class X> void f(A<X>) { }
      |                                                   ^
p431.cpp:202:31: error: 'B' is not a template
  202 |      template<class T> struct B { };
      |                               ^
p431.cpp:31:13: note: previous declaration here
   31 |      struct B : A { /* ... */ };
      |             ^
p431.cpp:203:6: error: 'A' is not a template
  203 |      A<B> ab;
      |      ^
p431.cpp:204:2: error: expected constructor, destructor, or type conversion before '(' token
  204 | f(ab); // calls f(A<B>)
      |  ^
p431.cpp:215:5: error: 'Y<> y1' redeclared as different kind of entity
  215 | Y<> y1;
      |     ^~
In file included from /usr/include/features.h:461,
                 from /usr/local/include/c++/12.1.0/x86_64-linux-gnu/bits/os_defines.h:39,
                 from /usr/local/include/c++/12.1.0/x86_64-linux-gnu/bits/c++config.h:655,
                 from /usr/local/include/c++/12.1.0/iostream:38,
                 from p431.cpp:10:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:221:1: note: previous declaration 'double y1(double)'
  221 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~

検討事項(agenda)

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

参考資料(reference)

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

コンパイラの実装状況

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

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

自己参照(self reference)

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

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

dockerにclang

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

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

Compare the contents of C++N4910:2022, C++N4741:2018 and C++N4606:2015

C++ sample list

clang++, g++コンパイルエラー方針の違いの例

astyle 使ってみた

C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

Clang/Clang++(LLVM) gcc/g++(GNU) コンパイラ警告等比較
https://qiita.com/kaizen_nagoya/items/9a82b958cc3aeef0403f

C++2003とC++2017でコンパイルエラーになるならない事例集
https://qiita.com/kaizen_nagoya/items/a13ea3823441c430edff

Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d

cpprefjpのdecltypeをコンパイル試験
https://qiita.com/kaizen_nagoya/items/090909af702f0d5d8a67

MISRA C++ 5-0-16
https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74

C++ Templates Part1 BASICS Chapter 3. Class Templates 3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed

ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1

C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

'wchar.h' file not found で困った clang++ macOS
https://qiita.com/kaizen_nagoya/items/de15cd46d657517fac11

Open POSIX Test Suiteの使い方を調べはじめました
https://qiita.com/kaizen_nagoya/items/644d5e407f5faf96e6dc

MISRA-C 2012 Referenceに掲載している文献の入手可能性を確認
https://qiita.com/kaizen_nagoya/items/96dc8b125e462d5575bb

どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00

MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9

「C++完全理解ガイド」の同意できること上位10
https://qiita.com/kaizen_nagoya/items/aa5744e0c4a8618c7671

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

文書履歴(document history)

ver. 0.01 初稿  20220706

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?