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更接 ...
随机推荐
- k8s授权访问
#监听本地的8080端口 kubectl proxy --port=8080 [root@k8s-m ~]# kubectl proxy --port=8080Starting to serve o ...
- video maker & video tutorials
video maker & video tutorials 视频课程制作工具 https://ke.qq.com/agency/personal/intro.html 成为网络老师 https ...
- PHPWord插件详解
一下载PHPWorld并配置项目 1.PHPWord框架文件如下: 二使用word模板并使用PHPWord生成doc文件 例如:源代码如下: <?php require_once '../PHP ...
- AngularJS从入门到精通
第一 AngularJS的四大特性 1. MVC 例如:使用angularjs向模板传递数据 <!doctype html> <html> <head> <m ...
- servletContext和request对象的生命周期比较
ServletContext: 创建:服务器启动 销毁:服务器关闭 域的作用范围:整个web应用 Request: 创建:访问时创建request 销毁:响应结束request销毁 域的作用范围:一次 ...
- 扩展运算符(spread)是三个点(…)
扩展运算符(spread)是三个点(…),将一个数组||类数组||字符串转为用逗号分隔的序列. js中用来对数组进行操作,把数组里面的东西统统拿出来 一.展开数组 //展开数组 let a = [1, ...
- 1、linux下对绝对路径和相对路径
cd / 回到根目录 cd /etc 回到根目录下的etc 目录下 绝对路径 路径写法是从根目录/ 写起来的. cd . 当前目录 cd .. 上层目录 cd ~回到自家的根目 ...
- docker --环境变量制作模板
比如你现在有配置文件:decoder.conf decoder.conf里面有两个配置项写的是: THREAD_NUM:24 GPU_ID:0 现在你希望通过某个统一的配置来修改这些配置项,以免在部署 ...
- 基准对象object中的基础类型----列表 (四)
object有如下子类: CLASSES object basestring str unicode buffer bytearray classmethod complex dict enumera ...
- 学习Android过程中遇到的未解决问题(个人笔记,细节补充,随时更新)
201811/13 使用HttpURLConnection对象调用方法又出现IO异常,我又百度个博客搜寻答案,未果.下午试试真机,完美.自己建了服务器tomcat,编写android访问自己tomca ...