Hi, @otaky
template<int N> void func2(int a = N)
provides default parameter a=N
.
template<> void func2<10>(int b)
is a specialization of template<int N> void func2(int a = N)
.
Declaration (and function signature) is determined by the primary template.
Since func2<10>()
has no parameter input. It uses default parameter N
10.
Below is a simplified example:
#include <iostream>
using namespace std;
template<int N> void func2(int a = N);
template<> void func2<10>(int b) {
cout << "func2<10>:" << b << endl;
}
int main(void) {
func2<10>();
}
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.