当前位置:网站首页>A problem about function template specialization
A problem about function template specialization
2022-07-02 01:09:00 【Don't run, you】
First , Remember that function template specialization must require an original template , To specialize function templates , Otherwise, an error will be reported “ It is not a display specialization of function templates ”
( Be careful : The original template and the specialized template should be in the same form , You can't add anything else )
such as :
#include<iostream>
#include<cstring>
typedef const char*pd;
template<typename T> // The original template
T max(T a,T b)
{
return (a>b?a:b);
}
template<> // Function template specialization
pd max<pd>(pd a,pd b)
{
return (strcmp(a,b)>0?a:b);
}
int main()
{
cout<<"max(7,8)="<<max(7,8)<<endl;
s1="hello";
s2="welcome";
cout<<"max(s1,s2)"<<max(s1,s2)<<endl;
return 0;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
After changing to this, there is no function template display , But there are functions max heavy load , Then I thought about ,C++ in max Function is a function of the system , hold max Change to Max Just fine .
边栏推荐
- PLC Analog input analog conversion FB s_ ITR (Mitsubishi FX3U)
- Datawhale 社区黑板报(第1期)
- Global and Chinese market of wireless chipsets 2022-2028: Research Report on technology, participants, trends, market size and share
- [eight sorts ①] insert sort (direct insert sort, Hill sort)
- Sql--- related transactions
- XMind思维导图
- gradle
- The pain of Xiao Sha
- Design and control of multi rotor aircraft (VII) -- sensor calibration and measurement model
- Global and Chinese market of ancillary software 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code

Keepalived introduction and installation
![[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login](/img/c1/23be4399119f42d85a7b86fc8a59fc.png)
[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login

SQL injection for Web Security (2)
![[eight sorts ②] select sort (select sort, heap sort)](/img/4b/da0d08230391d6ee48cd8cfd2f7240.png)
[eight sorts ②] select sort (select sort, heap sort)

【八大排序①】插入排序(直接插入排序、希尔排序)

DTL dephossite | prediction method of dephosphorylation sites based on Transfer Learning

2022 high altitude installation, maintenance and removal of test question simulation test platform operation

Collection: comprehensive summary of storage knowledge

JMeter做接口测试,如何提取登录Cookie
随机推荐
Global and Chinese market of wireless chipsets 2022-2028: Research Report on technology, participants, trends, market size and share
From 20s to 500ms, I used these three methods
关于ASP.NET CORE使用DateTime日期类型参数的一个小细节
Otaku wallpaper Daquan wechat applet source code - with dynamic wallpaper to support a variety of traffic owners
449 original code, complement code, inverse code
cookie、session、tooken
Design and control of multi rotor aircraft (VII) -- sensor calibration and measurement model
[dynamic planning] interval dp:p3205 Chorus
Global and Chinese markets for freight and logistics 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of safety detection systems 2022-2028: Research Report on technology, participants, trends, market size and share
Review notes of compilation principles
How does schedulerx help users solve the problem of distributed task scheduling?
Source code of Qiwei automatic card issuing system
sso单点登录的实现。
Global and Chinese markets of digital crosspoint switches and mux/demux 2022-2028: Research Report on technology, participants, trends, market size and share
Synthetic watermelon game wechat applet source code / wechat game applet source code
Zak's latest "neural information transmission", with slides and videos
Entrepreneurship is a little risky. Read the data and do a business analysis
什么是商业养老保险?商业养老保险安全靠谱吗?
Datawhale community blackboard newspaper (issue 1)