[英]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.