腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
3
回答
为什么
std
::
map
没有
FindOrNull
方法
c++
FindOrNull
比内置的find要简洁得多。比较 if (auto iter =
map
.find("key"); iter !=
map
.end()) { } if (auto value = GetMap().find_or_null("key"))
浏览 56
提问于2020-02-08
得票数 1
1
回答
理解tensorflow c++ API中的代码
c++
、
tensorflow
// This file provides utility functions for use with STL
map
-like data#define TENSORFLOW_LIB_GTL_
MAP
_UTIL_H_ #include <stddef.h>or NU
浏览 2
提问于2016-05-21
得票数 0
回答已采纳
1
回答
为什么
Map
没有
map
方法
?
javascript
、
ecmascript-6
为了“映射”
Map
对象,您必须首先将其解构为数组的数组。这对我来说似乎是倒退的。let mappedMap = new
Map
( .
map
(([k, v]) => [k * 2, '_' + v]) );let m
浏览 5
提问于2015-09-01
得票数 5
5
回答
为什么
std
::
map
没有
常量访问器?
c++
、
c++11
、
std
std
::
map
上的[]运算符的声明如下:有什么原因不是这样的吗?T& operator[] ( const key_type& x );因为当您需要访问const
方法
中的成员映射时
浏览 0
提问于2012-12-16
得票数 69
回答已采纳
1
回答
为什么
std
::
map
<
std
::
map
>不释放内存?
c++
、
c++11
、
memory-management
在下面的测试程序中,
std
::
map
分配的内存
没有
被释放。总而言之,我们分配了大约2.2 GB的内存,这些内存永远不会被释放,尽管我们用一个空容器进行了交换。当将
std
::
map
<
std
::
map
>更改为
std
::
map
<
std
::vector >时,实际上释放了内存。 我已经用valgrind检查了代码,它显然
没有
发现任何泄漏。
为什么
会这样,我该如何
浏览 1
提问于2016-06-02
得票数 10
2
回答
为什么
std
::insert需要CopyConstructibility?
c++
为什么
这些代码不能工作?对于
std
::
map
:的插入
方法
,文档中
没有
任何关于CopyConstructibility的内容。我可以构造
std
::结对,第二个元素是我的non_copyable类,但是我不能将它插入到映射中,即使insert
方法
的第一个重载需要一个const value_type&,所以这应该很好。有人能帮我理解
为什么
std
::
map
需要这个CopyConstructibility吗?#incl
浏览 0
提问于2018-02-15
得票数 1
回答已采纳
2
回答
插入无序映射的更快
方法
c++
我有一个无序的映射,就像这样:在向其中插入值时
为什么
?
方法
1(骨架):for (int i = 0; i < n; ++i) {
std
::string va
浏览 48
提问于2019-04-10
得票数 0
回答已采纳
1
回答
在嵌套无序映射中插入或更新键
c++
、
nested
、
unordered-map
std
::unordered_
map
<
std
::string,
std
::unordered_
map
<
std
::string,
std
::string>> maps;if (iter == maps[command[1]].end() || command[2] < iter->first) { maps[command[1]].insert(iter,
std
com
浏览 0
提问于2019-03-29
得票数 0
回答已采纳
1
回答
为什么
源
std
::
map
不用于
std
::
map
::merge?
c++
、
c++17
有什么理由void
std
::
map
<Key,T,Compare,Allocator>::merge(
std
::
map
<Key, T, C2, Allocator也许我在这里有一个高级时刻,但我看不出source是如何被这个函数改变的,而且它对它的方式
没有
多大帮助。
浏览 4
提问于2022-10-21
得票数 5
回答已采纳
1
回答
如何将
std
::
map
<int、MyObject>序列化/反序列化为C++中的json
c++
、
json
、
c++11
、
nlohmann-json
我试图使用
std
::
map
<int, MyObject>序列化/反序列化 它说映射的键必须能够生成
std
::string。我怎样才能做到这一点?我最不想做的就是实现void to_json(json& j, const
std
::
map
<int, MyObject>& p)和void from_json(const json& j,
std
::
map
<int, MyObject>& p)。由于
浏览 8
提问于2020-08-30
得票数 1
回答已采纳
1
回答
为什么
反向迭代器.rbegin()不能被用作要擦除的元素集的位置?
c++
、
iterator
、
c++17
、
c++-standard-library
、
reverse-iterator
std
::
map
.rbegin()的反向迭代器返回包含
std
::
map
中最大的key_type的元素的位置。
为什么
我可以访问但不能删除相同的位置?(
map
.rbegin().base())); //Erase the largest element in the
map
- WORKS 在我看来,如果一个函数/
方法
只需要一个迭代器来获得一个位置注意:我
没有
问"",我在代码的最后一行提
浏览 7
提问于2020-12-07
得票数 0
2
回答
为什么
std
::地图带一对?
c++
、
stl
这一语法:m.insert(
std
::make_pair(1, 42));
std
::
map
<int, int> m;是的,我知道m[1] = 42,但它有自己的问题
浏览 4
提问于2017-01-06
得票数 2
回答已采纳
1
回答
为什么
std
::set /
std
::
map
和
std
::unordered_set /
std
::unordered_
map
没有
std
::擦除重载,但是有
std
::erase_if?
c++
、
c++20
std
::erase /
std
::erase_if对所有序列容器(e.g.vector / array / list)都有重载。但是关联容器(例如set /
map
)只有
std
::erase_if。有人知道
为什么
吗?
浏览 6
提问于2022-01-26
得票数 2
2
回答
将本地结构传递给count_if
c++
、
g++
当我尝试编译(使用g++ 4.5.3,而不是使用c++03或c++11扩展)时,我在fail()
方法
中得到一个错误,但是pass()
方法
没有
这个错误。我不明白
为什么
在函数的外部和内部声明它会产生不同的效果。我遗漏了什么?#include <
map
>{ b
浏览 4
提问于2013-12-27
得票数 4
回答已采纳
1
回答
为什么
C++中
没有
像Java那样的Hashmap?
c++
、
data-structures
、
hashing
、
map
我知道C++标准库包括有序的和无序的映射(
std
::
map
和
std
::unordered_
map
)容器,但是
为什么
C++上
没有
hashmap?在我的一次编码面试中,有人问我这个问题,但我
没有
答案。甚至谷歌也
没有
给我一个满意的答案,只是给了我使用无序地图和解决hashmap问题的
方法
。
浏览 0
提问于2022-02-07
得票数 0
回答已采纳
5
回答
C++ const::
map
引用编译失败
c++
、
find
、
std
、
operator-keyword
、
stdmap
为什么
将对
std
::
map
的引用传递为const会导致[]运算符中断?当我使用const时,我会得到这个编译器错误(gcc 4.2): void func(const char ch,
std
::string &str, const
std
::
map
<
std
::string,
std
::string> &
map
); 而且,我应该指
浏览 13
提问于2009-03-26
得票数 17
回答已采纳
2
回答
如何从const中获取密钥的值?
c++
、
c++11
、
unordered-map
为什么
我不能在传递给函数的const unordered_
map
中获得键的值,但对于本地unordered_
map
却可以?GameObject(const
std
::unordered_
map
<int,
std
::unordered_
map
<int,int>>& objectParameters){
浏览 3
提问于2018-05-03
得票数 1
回答已采纳
1
回答
为什么
有序的
std
::
map
和ordered::set不被邀请制作transaction_safe?
c++
、
concurrency
、
stl
、
c++14
、
transactional-memory
operator[]声明为transaction_safe只适用于容器:
std
::vector,
std
::unordered_
map
,
std
::unordered_multimap,
std
::unordered_set,
std
::unordered_multiset,
std
::deque -从n4514:获得 23.4.4类模板地图在23.4.4.1但是
为什么</em
浏览 4
提问于2016-08-03
得票数 3
回答已采纳
3
回答
为什么
以下内容不编译?
c++
、
unordered-map
sstruct {
std
::string_view name; return "";}; "
浏览 12
提问于2022-04-06
得票数 2
回答已采纳
2
回答
为什么
我可以将boost
map
_list_of传递给接受映射而不是构造函数的函数?
c++
、
boost
、
constructor
、
stl
、
stdmap
我试图构造一个以
std
::
map
作为参数的对象,
方法
是使用boost
map
_list_of传递映射内容。这会产生编译错误,但是,当我尝试对接受
std
::
map
的常规函数做同样的操作时,它会编译得很好!&)’ is ambiguous note: candidates are: Blah::Blah(
std
::
map
<int, int,
std
::less<int>,
std
::alloca
浏览 3
提问于2015-10-01
得票数 8
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
对象存储
云点播
即时通信 IM
活动推荐
运营活动
广告
关闭
领券