Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterator resulting from find() cannot be compared to cend() #41

Open
instibrad opened this issue Jul 22, 2020 · 0 comments
Open

iterator resulting from find() cannot be compared to cend() #41

instibrad opened this issue Jul 22, 2020 · 0 comments

Comments

@instibrad
Copy link

Test code:
`TEST(sparsehash, densehashmap) {
google::dense_hash_map<uint32_t, std::string> map;

map.set_empty_key(0);
map.set_deleted_key(std::numeric_limits<uint32_t>::max());

EXPECT_TRUE(map.find(1) == map.cend());

}
`

results in compile error:
In file included from /home/bgreen/dev/git/edge-suite/ext/googletest/include/gtest/gtest.h:58, from /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:11: /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp: In member function ?virtual void sparsehash_densehashmap_Test::TestBody()?: /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:22:29: error: no match for ?operator==? (operand types are ?google::dense_hash_map<unsigned int, std::basic_string<char> >::iterator? {aka ?google::dense_hashtable_iterator<std::pair<const unsigned int, std::basic_string<char> >, unsigned int, std::hash<unsigned int>, google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey, google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > > >?} and ?google::dense_hash_map<unsigned int, std::basic_string<char> >::const_iterator? {aka ?google::dense_hashtable_const_iterator<std::pair<const unsigned int, std::basic_string<char> >, unsigned int, std::hash<unsigned int>, google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey, google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > > >?}) EXPECT_TRUE(map.find(1) == map.cend()); ~~~~~~~~~~~~^~~~~~~~~~~~~ /home/bgreen/dev/git/edge-suite/ext/googletest/include/gtest/internal/gtest-internal.h:1189:34: note: in definition of macro ?GTEST_TEST_BOOLEAN_? ::testing::AssertionResult(expression)) \ ^~~~~~~~~~ /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:22:5: note: in expansion of macro ?EXPECT_TRUE? EXPECT_TRUE(map.find(1) == map.cend()); ^~~~~~~~~~~ In file included from /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/dense_hash_map:105, from /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:13: /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/internal/densehashtable.h:192:8: note: candidate: ?bool google::dense_hashtable_iterator<V, K, HF, ExK, SetK, EqK, A>::operator==(const iterator&) const [with V = std::pair<const unsigned int, std::basic_string<char> >; K = unsigned int; HF = std::hash<unsigned int>; ExK = google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey; SetK = google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey; EqK = std::equal_to<unsigned int>; A = google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > >; google::dense_hashtable_iterator<V, K, HF, ExK, SetK, EqK, A>::iterator = google::dense_hashtable_iterator<std::pair<const unsigned int, std::basic_string<char> >, unsigned int, std::hash<unsigned int>, google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey, google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > > >]? bool operator==(const iterator& it) const { return pos == it.pos; } ^~~~~~~~ /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/internal/densehashtable.h:192:8: note: no known conversion for argument 1 from ?google::dense_hash_map<unsigned int, std::basic_string<char> >::const_iterator? {aka ?google::dense_hashtable_const_iterator<std::pair<const unsigned int, std::basic_string<char> >, unsigned int, std::hash<unsigned int>, google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey, google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > > >?} to ?const iterator&? {aka ?const google::dense_hashtable_iterator<std::pair<const unsigned int, std::basic_string<char> >, unsigned int, std::hash<unsigned int>, google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey, google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > > >&?} In file included from /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/internal/densehashtable.h:102, from /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/dense_hash_map:105, from /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:13: /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/internal/libc_allocator_with_realloc.h:102:13: note: candidate: ?template<class T> bool google::operator==(const google::libc_allocator_with_realloc<U>&, const google::libc_allocator_with_realloc<U>&)? inline bool operator==(const libc_allocator_with_realloc<T>&, ^~~~~~~~ /home/bgreen/dev/git/edge-suite/ext/sparsehash/include/sparsehash/internal/libc_allocator_with_realloc.h:102:13: note: template argument deduction/substitution failed: In file included from /home/bgreen/dev/git/edge-suite/ext/googletest/include/gtest/gtest.h:58, from /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:11: /home/bgreen/dev/git/edge-suite/baselib/test/unit/ext/sparsehash-unit.cpp:22:41: note: ?google::dense_hash_map<unsigned int, std::basic_string<char> >::iterator? {aka ?google::dense_hashtable_iterator<std::pair<const unsigned int, std::basic_string<char> >, unsigned int, std::hash<unsigned int>, google::dense_hash_map<unsigned int, std::basic_string<char> >::SelectKey, google::dense_hash_map<unsigned int, std::basic_string<char> >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<const unsigned int, std::basic_string<char> > > >?} is not derived from ?const google::libc_allocator_with_realloc<U>? EXPECT_TRUE(map.find(1) == map.cend());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant