Effective C++ .44 typename和class的不同
在C++模板中的类型参数一般可以使用typename和class,两者没有什么不同。但是typename比class多项功能:
“任何时候当你想要在template中指涉一个嵌套从属类型名称,就必须在其前面加上关键字typename”
因为C++默认情况下把属性都作为值来看待而不是类型。
#include <iostream>
#include <cstdlib> class Integer {
public:
typedef int value_type;
}; class Double {
public:
typedef double value_type;
}; template<class DataType>
class Storage {
public:
typename DataType::value_type data;
}; int main() {
Storage<Integer> s; s.data = 3.4/; std::cout<<s.data<<std::endl; return ;
}
Effective C++ .44 typename和class的不同的更多相关文章
- Effective Java 44 Write doc comments for all exposed API elements
Principle You must precede every exported class, interface, constructor, method, and field declarati ...
- Effective Java Index
Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st langu ...
- DAY1 linux 50条命令
1. tar压缩,解压缩 tar -cvf *** (压缩) tar -xvf *** (解压缩) [root@bogon ~]# tar cvf test.tar test/ test/ test ...
- C++ 仿函数/函数指针/闭包lambda
在上一篇文章中介绍了C++11新引入的lambda表达式(C++支持闭包的实现),现在我们看一下lambda的出现对于我们编程习惯的影响,毕竟,C++11历经10年磨砺,出140新feature,对于 ...
- 50个最常用的Linux命令
转载至:http://gywbd.github.io/posts/2014/8/50-linux-commands.html tar grep find ssh sed awk vim diff so ...
- linux 常用 掌握要点 详细终结
linux 命令大全 每个开发者应该了解的 10 个 Linux 命令 1.查看正在执行的进程(Process) ps命令 Process Status 进程状态 语法: ps [option] ...
- Linux常用的50个命令
50个最常用的Unix/Linux命令 2014-08-20 这篇文章翻译自http://www.thegeekstuff.com/2010/11/50-linux-commands/这些都是一些很常 ...
- 50个最常用的UNIX/Linux命令
转自http://get.jobdeer.com/493.get 1. tar command examples Create a new tar archive. $ tar cvf archive ...
- 写代码怎能不会这些Linux命令?
转自:https://zhuanlan.zhihu.com/p/28674639?hmsr=toutiao.io&utm_medium=toutiao.io&utm_source=to ...
随机推荐
- 使用 final 关键字修饰一个变量时,是引用不能变,还是引用的对象不能变?
使用 final 关键字修饰一个变量时,是指引用变量不能变,引用变量所指向的对象中的内容还是可以改变的.例如,对于如下语句:final StringBuffer a=new StringBuffer( ...
- Python脚本模板
1.Python脚本规范基础模板 #coding:utf8 import time, re, os, sys, time,urllib2,shutil,string import json,datet ...
- VMware安装黑威联通教程+文件 亲身测试成功 老骥伏枥黑威联通母盘QNAP1G-BOOT 1G
1.首先致敬老骥伏枥大神的帖子. [老骥伏枥-原创]制作黑威联通启动盘:进阶篇 2.其次感谢这位作者的安装教程 作者:f541883216 [老骥伏枥-原创]用我的黑威联通启动盘在WMware搭建系统 ...
- urllib和urllib3
urllib库 urllib 是一个用来处理网络请求的python标准库,它包含4个模块. urllib.request---请求模块,用于发起网络请求 urllib.parse---解析模块,用于解 ...
- AWS S3
Amazon Simple Storage Service (Amazon S3) Amazon S3 提供了一个简单 Web 服务接口,可用于随时在 Web 上的任何位置存储和检索任何数量的数据.此 ...
- RabbitMQ 很成熟 不是阿里的
简介 官网 http://www.rabbitmq.com RabbitMQ是一个由erlang开发的AMQP(Advanced Message Queue )的开源实现 RabbitMQ实现了AMQ ...
- gVim安装vim-template插件后提示Undefined variable vim_template_subtype/Press ENTER or type command to continue
Win7 64位 gVim:version 8.1.1234 vim-template:github链接 安装方式: 直接下载master的zip压缩包,解压后放入本地gVim安装目录的plugin, ...
- python namedtuple命名元组
from collections import namedtuple Animal=namedtuple('Animal','name age type') perry=Animal(name='pe ...
- JAVA统计一定范围内的质数个数
public class TestNumber{ public static void main(String[] args){ System.out.println(roundPrimeCount( ...
- (转)MyISAM Key Cache详解及优化
原文:http://huanghualiang.blog.51cto.com/6782683/1372721 一.MyISAM Key Cache详解: 为了最小化磁盘I/O,MyISAM将最频繁访问 ...