Template parameters (C++ only)
来源:互联网 发布:oppo手机数据恢复 编辑:程序博客网 时间:2024/05/21 14:45
在C++中有三种模板参数:
- Type template parameters (C++ only)
- Non-type template parameters (C++ only)
- Template template parameters (C++ only)
在模板参数的声明中即可以使用关键字class也可以使用关键字typename,但是在模板参数的声明中不能指定存储的类型(static 和 auto)
1.Type template parameters (C++ only)
Type template parameter 声明语法 >>-+-class----+--identifier--+---------+----------------------->< '-typename-' '-=--type-' identifier 是type的名字.
2.Non-type template parameters (C++ only)
non-type template parameter 的语法声明类似于下面几种形式之一:
- 整型或枚举
- 对象或函数的指针
- 对象或函数的引用
- 成员指针
被声明为数组或函数的Non-type template parameters 被分别转化为了指针或者函数指针.
template<int a[4]> struct A { };template<int f(int)> struct B { };int i;int g(int) { return 0;}A<&i> x;B<&g> y;
你可以用const 或 volatile限定 non-type template parameter.不能将non-type template parameter 声明为float point, class,或 void type.
Non-type template parameters 不是lvalues.
3.Template template parameters (C++ only)
Template template parameter 声明语法 >>-template--<--template-parameter-list-->--class--+------------+--+------------------+->< '-identifier-' '-=--id-expression-'
下面是用 template template paramete的一个例子:
template<template <class T> class X> class A { };template<class T> class B { };A<B> a;
- Template parameters (C++ only)
- Template Template Parameters(双重模板参数)
- C++ non type template parameters
- Expression parameters.parseContent is undefined on line 45, column 28 in template/ajax/head.ftl. - C
- Nontype template parameters(非型别模板参数)
- C++template
- C template
- C++Template
- FreeMarker template error!stack.findValue(parameters.listKey) is undefined.
- C++ Knowledge share: 3 kinds of template parameters
- Nontype Class Template Parameters(非类型类模板参数)
- 解决RabbitMQ service is already present - only updating service parameters
- @Field parameters can only be used with form encoding
- @Field parameters can only be used with form encoding
- c++ template笔记(3)非类型模板参数nontype template parameters
- Parameters
- Parameters
- Parameters
- 编程这种感觉
- CE 6内存模型
- 用emacs编辑c#
- FreeMicaps开发---图层管理
- ORACLE执行计划的一些基本概念
- Template parameters (C++ only)
- Eclipse 常用快捷键
- 我喜欢写CODING
- mysql timestamp 基本用法
- 跟踪SQL_TRACE
- test
- 习题 54: 邮递员★★★
- 广义表
- 结合Spring2.0和ActiveMQ进行异步消息调用(转)