简体   繁体   English

我如何使用 unordered_map<string::iterator, string> ?</string::iterator,>

[英]How can I use unordered_map<string::iterator, string>?

I have a function with the following signature:我有一个具有以下签名的 function:

void findDotStars(unordered_map<string::iterator, string>& fp, string& p)

I get C2280 compiler's error.我得到C2280编译器的错误。 I need to store pointers to parts of string.我需要存储指向字符串部分的指针。 I think that I need to convert iterator to pointer, but to which pointer?我认为我需要将迭代器转换为指针,但是转换为哪个指针?

The type std::string::iterator is implementation defined, so there might or might not be a specialisation of std::hash for it. std::string::iterator类型是实现定义的,因此可能有也可能没有std::hash的特化。 If there isn't, then you need to write one.如果没有,那么你需要写一个。 If there is, then you must not write one.如果有,那么你不能写一个。

There definitely will be a specialisation for std::string::pointer , so you could use that instead, although you will have to be careful about iterator's that equal the string's end() . std::string::pointer肯定会有一个特化,所以你可以使用它,尽管你必须小心迭代器等于字符串的end()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 unordered_map 迭代器指向 end(),如何从 unordered_map 中检索键? - unordered_map iterator points to end(), how can I retrieve a key from unordered_map? 如何为字符串创建unordered_map以实现功能 - How to create an unordered_map for string to function 为什么我不能增加std :: unordered_map迭代器? - Why can't I increment std::unordered_map iterator? 如何将 typedef 与 unordered_map::const_iterator 一起使用? - How to use typedef with unordered_map::const_iterator? 如何散列std :: unordered_map :: const_iterator? - How can I hash a std::unordered_map::const_iterator? 如何使用std :: string中的unordered_map对字符串文字进行is_transparent功能? - How to use is_transparent feature on a string literal with unordered_map from std::string? 当wordCount中不存在key时,我应该将++ wordCount [key]用于unordered_map <string,int>吗? - should I use ++wordCount[key] for unordered_map<string, int> when key doesn't exist in wordCount? 我可以创建一个字符串和原子的unordered_map吗 <int> 键值对? - Can I create an unordered_map of string and atomic<int> key-value pairs? 如何使boost unordered_map支持flyweight <string> - How to make boost unordered_map to support flyweight<string> 将unordered_map迭代器更改? - will unordered_map iterator change?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM