template specifiers not specified in declaration of ‘template<class Key> class hash’
尝试写显示特化样例的时候,写了如下代码
#include <iostream>
#include <cstddef> using namespace std; #define __STL_TEMPLATE_NULL template<> template<class Key>
class hash {
public:
void operator()() {
cout << "Hash<T>" << endl;
}
}; //explicit specialization
__STL_TEMPLATE_NULL
class hash<char> {//template specifiers not specified in declaration of ‘template<class Key> class hash’
public:
void operator()() {
cout << "Hash<char" << endl;
}
};
编译时 在红色注释处报错
然后找原因半天找不到
换种写法,出现以下错误
C++::EC - expected initializer before '<' token
根据别人的文章才知道有类名“hash“有混淆。
解决方法:改一下名字,加个命名空间,或者去掉<cstddef>头文件应该就可以了
template specifiers not specified in declaration of ‘template<class Key> class hash’的更多相关文章
- Template within template: why “`>>' should be `> >' within a nested template argument list” 解决方法
如果直接这样写: std::vector<boost::shared_ptr<int>> intvec; gcc编译器会把">>"当成opera ...
- 模板(Template)
最近阅读google chromium base container stack_container代码,深刻感觉到基础知识不扎实. // Casts the buffer in its right ...
- How to organize the Template Files in C++
Normally you put class definitions in a header file and method definitions in a source file. Code th ...
- C++ Knowledge series Template & Class
Function Function is composed of name, parameter (operand, type of operand), return value, body with ...
- Package template (html/template) ... Types HTML, JS, URL, and others from content.go can carry safe content that is exempted from escaping. ... (*Template) Funcs ..
https://godoc.org/text/template GoDoc Home About Go: text/templateIndex | Examples | Files | Directo ...
- C++对象模型——Template中的名称决议方式 (第七章)
Template中的名称决议方式 (Name Resolution within a Template) 必须可以区分下面两种意义,一种是C++ Standard所谓的"sope of th ...
- 关于template 的23个问题
发现新大陆.曾经慢慢才知道的东西.原来有个集中营: 看看updated, 处理方式是这么的好 35.1 " id="link-to-faq-35_1" style=&qu ...
- C++ Templates (2.1 类模板Stack的实现 Implementation of Class Template Stack)
返回完整目录 目录 2.1 类模板Stack的实现 Implementation of Class Template Stack 2.1.1 声明类模板 Declaration of Class Te ...
- C++(VS2015)模板显式特化之template语法深入理解
首先说下遇到的情况: 这里在vc++6.0上建立了一个自定义模板类,再去覆盖这个类,分别使用部分覆盖,整体覆盖 但在vs2015上去整体覆盖类会报错. 错误如下: 错误原因:个人感觉是新版本的vs更接 ...
随机推荐
- docker学习笔记一
知识点: 1)docker简介 2)docker安装,仓库配置 3)docker仓库镜像拉取,导出,导入,删除 4)docker容器操作,容器的创建,删除,运行,停止,日志查看等. 5) docke ...
- 从git中删除 .idea 目录
将.idea目录加入ignore清单: $ echo '.idea' >> .gitignore 从git中删除idea: $ git rm —cached -r .idea 3 将. ...
- MyBatis基础:MyBatis数据基本操作(2)
1. MyBatis映射器 2. MyBatis数据基本操作 示例项目结构: <project xmlns="http://maven.apache.org/POM/4.0.0&quo ...
- FormDestroy 和 FormClose 有什么区别和联系?
1.窗口的所有资源真正释放时调用 FormDestroy.当你关闭窗口时,VCL会调用FormClose,如果你在FormClose里写Action = caFree,那么VCL会继续调用FormDe ...
- 插件 DataTable 创建列表 render参数的详解与如何传递本行数据id
1.首先 导入DataTable 的插件 2.定义表结构: HTML: <table> <thead> <tr> <th>id</th> & ...
- PHP namespace、require、use区别
假设 有文件a.php 代码 <?php class a{//类a public function afun()//函数afun { echo "aaaa"; } } ?&g ...
- ubuntu16.04下 搭建 lnmp 环境
apt-get install nginx apt-get php7.-mysql apt-get install mysql 编辑nginx配置文件 vim /etc/nginx/sites-ena ...
- Tyche 2191 WYF的递推式
题目描述 WYF手中有这样一条递推式 WYF并不是想让你帮他做出结果,事实上,给定一个n,他能够迅速算出Fn.WYF只是想单纯的考验一下读者们. 输入描述 仅一行,三个整数N,F1,P 输出描述 仅一 ...
- [CF1131C]Birthday【贪心】
题目描述 有 n n个数摆放在一个环形中(最后一个与第一个相邻),需要改变这些数的顺序,使得相邻两个数的最大绝对差最小.如果有多种最佳方案,输出任意一种. (翻译来自洛谷) 分析 首先收尾相接,那么很 ...
- [2017-7-25]Android Learning Day3
最近真的有点迷茫,感觉没有一个完整的教学体系很难进行下去,有的都是自己瞎捉摸,就跟以前ACM的时候一样,动不动就“这就是一道,水题暴力就行了”.“我们枚举一下所有的状态,找一下规律就行了”,mmp哟. ...