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更接 ...
随机推荐
- python SMTP 发送邮件 阿里企业邮箱、163邮箱 及535错误
class SendEmail(object): def __init__(self, type, to_addr): self.to_addr = to_addr self.sys_date = t ...
- 用dbExpress页的SQLConnection1连接sql server2000怎么设置。 [问题点数:0分]
在d7或者c6已经支持了. 贡献一下我的代码吧:dbeConn:= TSQLConnection.Create(nil); dbeConn.Params.Clear; dbeC ...
- vs code配置
新版的用户设置不是代码, https://blog.csdn.net/zhaojia92/article/details/53862840 https://www.cnblogs.com/why-no ...
- How to enable AHCI on Windows7
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\msahci
- size_t的使用
size_t的取值range是目标平台下最大可能的数组尺寸 典型的例子:x64平台下size_t是8位,而x32平台下是4位: int在两个平台下均为4位 所以在使用的时候一定要配置好对应的平台,否则 ...
- Zero to Build: Create new Xamarin apps in minutes with AppMap
Creating a new Xamarin.Forms app can be an intimidating task, especially if you add in content pages ...
- Xtoken
“我希望有一种模式,利用群体的智慧让最好的想法总能够脱颖而出”. 博弈模型 背景 本文为NEO社区理事会秘书长陶荣祺在全球创业周区块链创新与发展论坛上的主题演讲<Xtoken代观社区驱动群体智慧 ...
- Codeforces 798D Mike and distribution
题目链接 题目大意 给定两个序列a,b,要求找到不多于个下标,使得对于a,b这些下标所对应数的2倍大于所有数之和. N<=100000,所有输入大于0,保证有解. 因为明确的暗示,所以一定找个. ...
- 轻量级浏览器Midori
导读 这是一个对再次回归的轻量级.快速.开源的 Web 浏览器 Midori 的快速回顾. 如果你正在寻找一款轻量级网络浏览器替代品,请试试 Midori. Midori是一款开源的网络浏览器,它更注 ...
- 大佬RQY真的强
今天听了大佬RQY的讲话,做一下总结吧(这里就不吹了,dalao不需要吹) 第一点,基础真的很重要.什么是基础呢?就是你今年学的觉得难到爆啊什么鬼题啊这是我学过的最zz的东西啊怎么会有这种东西啊&am ...