腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
1
回答
在
处理
struct
模板
中
的
int
时
,
如何
修复
“
X
不是
类
模板
”?
c++
我无法编译我
的
代码,我尝试使用一个结构
模板
来存储有关类型信息
的
类
,这个结构
模板
接受一个
int
和一个参数包。Ts> typedef typename std::tuple_element<N, std::tuple<Ts...>::size;}; using types = type_info<bool,
int</em
浏览 13
提问于2019-01-17
得票数 3
回答已采纳
2
回答
导出/删除
模板
模板
参数
的
类型
c++
、
c++11
、
templates
、
variadic-templates
、
template-templates
当使用
模板
模板
参数
时
,
如何
推导或删除
模板
的
模板
类型?参数演绎为
模板
类
,比如Value和BadValue
类
,强制要求参数包
中
的
Print
类
中
的
所有
模板
参数都是同一个ValueType
模板
类
的
专门化--这是有意
的
。也就是说,main()函数<e
浏览 1
提问于2018-01-28
得票数 2
回答已采纳
1
回答
将
类
列表传递给
模板
c++
我想要创建一个管道,其中我会指定几个
处理
类
作为
模板
参数,然后
模板
会在它们之间传递数据等等。但是使用gcc/clang,我得到了“非命名空间范围
的
显式专门化”,或者“函数
模板
部分专门化是不允许
的
”,如果我尝试另一种方法。#include &l
浏览 4
提问于2017-03-12
得票数 0
回答已采纳
1
回答
使用不同编译器
的
VoidT会产生不同
的
结果。
c++
考虑以下代码:public:}; public:}; class B { test.cpp:24:7: error: previous definition of ‘class B<
浏览 2
提问于2019-10-10
得票数 10
回答已采纳
2
回答
模板
结构
中
的
静态函数不使用默认
模板
参数
c++
、
templates
、
struct
我有一段我无法编译
的
代码,我想知道是否有办法绕过它。错误是-
类
模板
"a“
的
参数列表丢失。//not compiling one
struct
a { static T function(T number) { } template <type
浏览 1
提问于2020-10-11
得票数 0
回答已采纳
2
回答
gcc为什么抱怨“错误:
模板
参数'0‘
的
'intT’类型取决于
模板
参数?
c++
、
templates
、
c++11
、
variadic-templates
、
template-meta-programming
我
的
编译器是gcc 4.9.0。无法编译下列代码:
struct
value {};
struct
value<T, 0> {}; //那么,
如何
解决这个问题呢?
浏览 4
提问于2014-07-09
得票数 3
回答已采纳
2
回答
C++
类
迭代器实用程序:定义和使用
c++
、
class
、
templates
、
iterator
、
typename
我有一个名为A
的
类
,在这个
类
中
我有一个可迭代
的
容器,我按照一些访问规则--顺序、空值和其他规则进行迭代。 // Some accessing policy }; std::vector<
int
> a;一切都非
浏览 2
提问于2013-03-09
得票数 2
回答已采纳
2
回答
模板
参数
中
的
类
指针-这对什么有用?
c++
、
templates
template <typename T>
struct
s{
struct
s<MyClass*> obj;template <>
struct
s<MyClass *>我不能添加指针变量(既
不是
常量也
不
浏览 0
提问于2013-03-02
得票数 0
回答已采纳
2
回答
如何
专门化
模板
子类?
c++
、
templates
、
template-specialization
我试图
在
另一个
类
中专门化一个
模板
类
,但是编译器不允许我这样做。代码
在
Foo
类
之外工作,但在内部不起作用,我希望
struct
对Foo
类
是私有的。Ts>
struct
Bla; }; error: explicit specializ
浏览 6
提问于2015-04-09
得票数 5
回答已采纳
1
回答
奇怪
的
嵌套
类
部分专门化对gcc和clang都有影响
c++
、
templates
、
c++11
、
language-lawyer
、
template-meta-programming
在编写一个供个人使用
的
小型
模板
元编程库
时
,我遇到了一个有趣
的
问题。
struct
vargs {}; {
struct
outer
浏览 1
提问于2015-07-13
得票数 24
回答已采纳
2
回答
从用户代码中注入默认
模板
参数类型
c++
、
templates
、
c++17
、
c++14
在
“
模板
成员函数
的
定义”之后,是否有方法“注入”
模板
类
的
模板
成员函数
的
默认类型?与此基本类似(不编译),以便在定义
模板
类
NS::Default及其成员函数
模板
的
库之外指定Z(Z
的
默认类型):namespace NS {}
struct
S {
浏览 6
提问于2022-02-10
得票数 2
回答已采纳
3
回答
在一般情况下,哪些情况需要
模板
参数才能完成?
c++
、
templates
考虑一下简单
的
代码:template<typename> void func(){} func<
x
>();} 上面的代码不要求
类
x
是完整
的
,还有其他不要求
x
完成
的
情况吗?此外,一般来说,需要
模板
参数才能完成
的
情况是什么?
浏览 4
提问于2015-12-15
得票数 3
回答已采纳
2
回答
如何
使用
模板
模板
参数专门化
类
模板
?
c++
、
templates
、
template-specialization
、
partial-specialization
我想在
模板
参数
的
类型
模板
参数上专门化一个
类
模板
。有可能吗?如果是,语法是什么?#include <type_traits>
struct
X
{}; template<template<classtemplate template parameter template <template<class> clas
浏览 1
提问于2015-12-22
得票数 2
回答已采纳
3
回答
为什么需要有两个不同
的
语法来专门化
类
模板
的
数据成员?
c++
、
templates
、
template-specialization
、
class-template
、
explicit-specialization
我正在编写一个涉及
类
模板
专门化
的
示例,其中我注意到该标准允许对数据成员进行两种不同
的
语法专门化,如下所示:
struct
C {};
struct
C<bool> {}; //here we cannot write pr
浏览 12
提问于2022-05-11
得票数 0
回答已采纳
3
回答
如何
将
模板
化类型初始化为清零POD数据或默认构造非POD数据?
c++
、
templates
、
c++03
在
C++ -03
中
给出一个
模板
化
的
C++函数:void example(data arg) { ...如果
模板
参数是POD,我
如何
将其置零(例如,
int
获取0,float获取0.0,等等)或者,对于非POD,使用它
的
默认构造函数?我看到对于
类<
浏览 2
提问于2015-07-12
得票数 2
1
回答
函数
模板
修改用顶级const: clang声明
的
参数?
c++
、
c++11
、
clang
、
c++14
下面的代码
在
clang 3.8.1-1 on ArchLinux上正确编译。gcc对此发出正确
的
警告/错误。template <class T> using size_type = typename T::size_type; }[nmmm@zenbook HM3]$ clang <
浏览 0
提问于2016-09-13
得票数 8
回答已采纳
2
回答
C++嵌套
模板
问题
c++
、
templates
、
g++
、
language-lawyer
、
clang++
我想知道这个语法是否有效(在这种情况下,我会把它报告为一个可能
的
clang )。
struct
Foo using Value =
int
;
struct
Bar;template<typename Foo<FOO>::Value VALUE>
struct</e
浏览 3
提问于2019-03-25
得票数 8
回答已采纳
4
回答
如何
读取
模板
的
部分专门化?
c++
、
templates
、
c++11
、
partial-specialization
假设以下声明:下面的部分专门化定义似乎使用相同
的
字母T来引用不同
的
类型。template <typename T>
struct
MyTemplate<T*> {};MyTemplate<
int
*> c;template <typename T>
浏览 7
提问于2015-08-02
得票数 3
回答已采纳
7
回答
嵌套
模板
专业化
c++
、
templates
做这样
的
事有可能吗?template<
int
a>
struct
Foo template<
int
b>
struct
Bar;P.S.:我忘了提到
在
Foo
的
范围内显式地专门针对Bar
的
语言不支持。总之,AFAICS。
浏览 2
提问于2009-02-20
得票数 24
2
回答
模板
类
内部
模板
类
的
模板
参数推演
c++
、
templates
我
在
另一个
模板
类
中有一个
模板
类
。
如何
编写一个可以接受内部/外部
模板
类
的
任意组合
的
模板
函数?template <class
X
>{
struct
B
int
q;}; template <clas
浏览 24
提问于2021-05-21
得票数 4
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
C程序员是怎样评判GO语言的
C++20:核心语言
从 Codable到Swift 元编程
《Effective Modern C+》笔记之类型推断
C+11使用using定义别名(替代typedef)
热门
标签
更多标签
云服务器
即时通信 IM
ICP备案
对象存储
实时音视频
活动推荐
运营活动
广告
关闭
领券