腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
std
::
map
中
的
模板
类型
c++11
、
templates
、
std
、
std-pair
我想创建一个成对
的
向量。其中一个成员是
std
::string,第二个成员是
模板
化
类型
。然而,这给我带来了编译错误:
std
::vector<
std
::pair<
std
::string, T> > arrayMembers; 这有可能吗?
浏览 9
提问于2018-07-27
得票数 0
1
回答
以
模板
作为返回
类型
的
Trompeloeil MAKE_MOCK0
c++
、
trompeloeil
当使用Trompeloeil模拟C++
中
的
单元测试时,如何使用作为返回
类型
?-
std
::unordered_
map
:使用类
模板
需要
模板
参数列表 - trompeloeil::param_list:
std
::_Hash<_Traits::size>不是参数
类型
T
的
有效
模板
类型
参数Sig‘
的
模板
参数,这是一个真实
的</em
浏览 10
提问于2021-01-20
得票数 2
回答已采纳
4
回答
在类
模板
中
创建地图元组
c++
、
c++11
struct VectorOfMaps {
std
::
map
<
std
::string,int>, > tuple;我想把它泛化到一个
模
浏览 0
提问于2013-05-05
得票数 2
回答已采纳
3
回答
接收任何标准映射
的
函数
模板
c++
、
templates
、
c++11
我正在写一个函数,它应该接收(
std
::
map
,
std
::multimap,
std
::unordered_
map
或
std
::unordered_multimap)
中
的
一个。我
的
代码如下: inline typename
std
::enable_if<
浏览 1
提问于2015-05-21
得票数 9
2
回答
模板
专门化
模板
c++
、
templates
有办法从
模板
专门化
中
获取
模板
吗?例如,来自
类型
为
std
::unordered_
map
的
变量
的
std
::unordered_
map
<char, char>作为
模板
参数传递。最起码
的
例子: template <template <class ...> class t_
浏览 2
提问于2016-02-12
得票数 5
回答已采纳
2
回答
在编译时创建所有可能
的
键值
类型
映射
的
变体
类型
,其中键和值
类型
是从
类型
的
元组指定
的
。
c++
、
templates
、
variadic-templates
、
template-meta-programming
目前,我有一个variant of
map
类型
,其中我硬编码所有键值对
的
变体,如下所示:
std
::
map
<int,
std
::string>,
std
::
map
<int,
浏览 1
提问于2018-03-26
得票数 1
回答已采纳
1
回答
如何使静态
map
<string、TNested>成为
模板
类
的
成员?
c++
、
templates
、
static
以下代码无法编译,出现以下错误: #include <iostream>#include <stri
浏览 2
提问于2015-08-12
得票数 2
3
回答
如何插入到
std
::
map
?
c++
、
stl
有没有一个
std
迭代器可以用来使用
std
算法(例如
std
::copy)将元素插入到
std
::
map
中
? 我需要一个容器来将一个对象链接到一个字符串,于是我考虑使用
std
::
map
。有没有更好
的
容器?
浏览 0
提问于2010-12-07
得票数 26
回答已采纳
2
回答
用较大
的
比较器初始化
map
c++
我感到困惑
的
是,为什么用
std
::less比较器初始化
map
是有效
的
,而
std
::works不起作用。 const Allocator& alloc = Allocator() ); typedef
std
::
map
<double,
std
::q
浏览 0
提问于2019-08-31
得票数 0
回答已采纳
1
回答
模板
类型
擦除
c++
、
templates
、
c++17
、
type-erasure
我想知道是否有一种使用C++17标准编写类似于以下代码
的
实用方法:#include <functional>struct Foo using arg_type = Arg; using fun_type =
std
::function< void(Arg&) >;
std
::unordered_
map
浏览 4
提问于2021-11-03
得票数 1
回答已采纳
2
回答
如何创建以键作为输入并在C++
std
:
map
中找到值
的
模板
函数?
c++
、
stdmap
、
function-templates
我有两个
std
:
map
,其中一个键
的
键是CustomClass1
类型
,另一个键是CustomClass2
类型
,但是它们
的
值
类型
相同,
std
::string。//first
map
//second
map
std
::
浏览 2
提问于2019-01-24
得票数 0
1
回答
为什么
std
::unordered_
map
不能与const
std
::string密钥一起使用?
c++
、
unordered-map
下面的代码示例不会编译,但是可以通过删除作为无序映射键
的
std
::string之前
的
const说明符来编译它。#include <unordered_
map
>#include <string>{int myint = 5;
std
::unordered_
map
<const
std
::string, int
浏览 5
提问于2018-05-30
得票数 1
1
回答
在不知道键
的
情况下获取
std
::
map
中
的
值
的
类型
c++
、
dictionary
、
reflection
、
stdmap
、
c++03
我有一个带有未知键和值
类型
的
映射,我想在不事先知道键
类型
的
情况下确定值
类型
的
typeid(...).name(): // This gives me thetypeid(...).name(), but requires knowing the key type有没有办法在不知道V是什么
类型
的</e
浏览 26
提问于2018-09-12
得票数 2
回答已采纳
1
回答
std
::
map
变压器
模板
c++
、
templates
、
transform
std
::
map
转换函数
的
以下
模板
不起作用。如果使用transform_
map
(),编译器将无法推断要查找
模板
的
类型
。怎么做呢?template <class Key, class FromValue, class ToValue, class Transformer>
std
::
map
<Key, ToValue> transform_
map
(const
std</e
浏览 0
提问于2018-06-15
得票数 3
回答已采纳
2
回答
安全地引用具有与
模板
不兼容
的
模板
参数
的
C++
模板
类型
?
c++
、
templates
、
language-lawyer
在下面的代码示例
中
,我定义了一个类DT (我
的
默认
类型
),希望它能够作为任意
模板
的
参数传递。在本例
中
,我将DT作为
std
::
map
的
键和值参数进行传递。我从来没有尝试过实例化
map
<DT,DT>,我只想使用
map
<DT,DT>作为
模板
参数,用于
模板
函数(在这个示例
中
,函数f()),它从不实际引用
类型
--它
浏览 0
提问于2019-04-28
得票数 3
回答已采纳
2
回答
std
::
模板
成员函数指针
的
映射
c++
、
c++11
我正在阅读这个
的
答案,并试图弄清楚如何在
std
::
map
中
存储
模板
成员函数指针c++11。class A { using MFP = T (A::*)(); MFP fp = fmap[s]; return (this->*fp
浏览 0
提问于2016-07-14
得票数 2
2
回答
模板
化
的
命名空间和typedefs是非法
的
--变通方法?
c++
、
function
、
templates
、
namespaces
、
typedef
我有一个
模板
化
的
函数fct,它基于
模板
参数使用一些复杂
的
数据结构。它还调用一些帮助器函数(在同一
类型
上
模板
化),这些函数位于单独
的
helpers名称空间中,并使用相同
的
复杂数据结构。fct(const
std
::vector<
std
::vector<
std
::
map
<T,
std
::set<T> > > >&am
浏览 2
提问于2009-04-15
得票数 1
回答已采纳
7
回答
C++
模板
化地图包含自身
c++
、
templates
、
recursion
、
stdmap
我有一个
模板
化
的
类,它可以有一个映射
类型
作为
模板
参数。template<typename
map
_t> class my_class
map
_t my_
map
;现在我希望
map
的
值
类型
等于这个类。my_class<
std
::
map
<
std
::string, my_class<...> > > pr
浏览 1
提问于2011-08-07
得票数 3
回答已采纳
1
回答
如何避免重复使用“索引技巧”?
c++
、
c++14
、
variadic-templates
、
idioms
、
index-sequence
有了这个类,我有了一个
std
::unordered_
map
<
std
::string, memory_region> my_
map
--它用来在我
的
代码
中
不共享头
的
部分之间传递
类型
擦除
的
跨度,所以它们不能知道彼此
的
类型
对其中之一
的
典型访问如下所示: auto foo = my_
map
.at("foo").as_span<bar_
浏览 3
提问于2017-08-22
得票数 4
2
回答
函数
模板
作为参数
c++
、
templates
、
c++11
、
function-pointers
我一直在尝试在C++11
中
实现来自Python
的
函数。它似乎适用于任何
类型
的
可调用对象,但如果我希望它与函数
模板
一起使用,我必须指定
模板
类型
参数。>, li))
std
::cout << i <<
std
::endl;}for(auto i: <em
浏览 2
提问于2013-04-28
得票数 4
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
实时音视频
对象存储
即时通信 IM
活动推荐
运营活动
广告
关闭
领券