#include <iostream>
#include <cstdlib>
#include <string> using namespace std; template<class T, class P>
T mul(T a, P b) {
return a * b;
} template<>
string mul<string, int>(string a, int b) {
string res;
for (int i=b; i>; i--) {
res.append(a);
}
return res;
} int main() {
cout<<mul(,)<<endl; cout<<mul(string("haha"),)<<endl;
return ;
}

traits对于基本类型可以采用特化方式为其'添加'一些属性(因为原本基本类型没有也不能在加入自定义的属性)

最新文章

  1. codegate-quals-2013-vuln100
  2. AOP和IOC的实现原理(用到的设计模式)
  3. Linux 下以其他用户身份运行程序—— su、sudo、runuser
  4. memcached for windows 修改端口和最大内存,以及常用命令
  5. mac上parallel与virtualbox无法共存
  6. 深入剖析PHP输入流 php://input (转载 http://www.nowamagic.net/academy/detail/12220520)
  7. WCF SOA服务应用
  8. Android 系统日期时间的获取
  9. C#学习日志 day8 -------------- async await 异步方法入门(引用博客)以及序列化和反序列化的XML及json实现
  10. osgi实战学习之路:3. osgi分层概念及相互合作demo
  11. Linux虚拟机下安装配置MySQL
  12. pulseaudio的交叉编译
  13. Excle巧取汉字打头的字串内容
  14. 练习:javascript分享划过简单效果
  15. Spark 广播变量BroadCast
  16. Java 基础 IO流
  17. 01:golang开发环境
  18. 大数据新手之路四:联合使用Flume和Kafka
  19. C# 程序设置开机启动(一)
  20. tag-SMASS-1

热门文章

  1. 从一个bug谈谈psqlodbc游标的一点认识
  2. php prepare
  3. 52.RocketMQ 事务
  4. [原创]PHP使用Redis实现Session共享
  5. linux下不同颜色文件的性质
  6. 【VS2015】关于VS2015如何运行的问题
  7. order by中用子查询排序
  8. Go语言容器
  9. [Xamarin] 透過 IsolatedStorageFile儲存資料(转帖)
  10. Spring Boot Starter列表