如果我有一个按字符串索引的unordered_sets的无序映射,例如 通用标签

关于使用此数据结构,我有几个问题。无论如何,我是否需要在映射中索引的集合中插入新值,而不必使用指向该集合的指针或为索引值重新索引?

第二个问题,当我尝试索引到地图时遇到一个未解决的外部符号错误。例如, 通用标签

我不确定为什么会导致未解决的符号错误,因此任何指导都将有所帮助。

预先感谢

编辑:UseMap [character]的任何使用都会导致未解决的符号错误

还添加了错误代码和源示例

全班 通用标签

以及完整的错误消息:

错误52错误LNK2001:未解析的外部符号“私有:静态类boost :: unordered_map,类std :: allocator>,类boost :: unordered_set,类std :: allocator>,结构boost :: hash,类std: :allocator>>,struct std :: equal_to,class std :: allocator>>,class std :: allocator,class std :: allocator>>>,struct boost :: hash,class std :: allocator>>,struct std :: equal_to,class std :: allocator>>,class std :: allocator,class std :: allocator> const,class boost :: unordered_set,class std :: allocator>,struct boost :: hash,class std :: allocator >>,结构std :: equal_to,类std :: allocator>>,类std :: allocator,类std :: allocator>>>>>> SingleUse :: UseMap“(?UseMap @ SingleUse @@ 0V?$ unordered_map @V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V?$ unordered_set @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V $ allocator @ D @ 2 @@ std @@ U?$ hash @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ boost @@ U $ equal_to @ V $ basic_string @ DU $ char_traits @ D @ std @@ V $ allocator @ D @ 2 @ std @@@ 2 @ V?$ allocator @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ 2 @@ boost @@ U?$ hash @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ 4 @ U?$ equal_to @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@@ 2 @ V?$ allocator @ U?$ pair @ $$ CBV?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V?$ unordered_set @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ U?$ hash @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ boost @@ U?$ equal_to @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@@ 2 @ V?$ allocator @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ 2 @@ boost @@@ std @@@ 2 @@ boost @@ A)G:\ Documents \ Programming Projects \ KHMP \ KHMP_Repo \ KHMP \ build \ KHMP \ KHMP \ KHMPMain.obj

有帮助吗?

解决方案

第一个问题,是的,只要将结果分配给引用,就可以了。

执行此操作: 通用标签

现在set是对映射中值的引用。(我不确定auto会为您提供什么,所以我将类型完整化;您也许可以摆脱使用auto的困扰。)您对set所做的任何更改都会反映在地图上。 通用标签

其他提示

好吧,未解析的符号是因为我没有在任何地方实例化静态变量。我忘了你必须用C ++做到这一点,这是我的错。感谢您提供的帮助

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top