Hello list,I try to use a SeqAn CharString as a key in an unordered_map (C++11). It fails when he tries to link. The linker message is posted below. I think the CharString type is not hashable, therefore I probably need to provide my own hash function (see below). Am I heading in the right direction? Before I start doing this I wanted to know why a string is hashable by the default function but not a CharString? Is there a trick to easily get around this?
Thanks, Oliver This is my map structure: unordered_map<CharString, unsigned int>I assume I have to do something like this to provide a hash function (found at stackoverflow):
template<> struct hash<typename CharString> { size_t operator() (CharString const &key) { // calculate hash value } }; Linker message: Linking CXX executable fastq_readerCMakeFiles/fastq_reader.dir/fastq_reader.cpp.o: In function `std::_Hashtable<seqan::String<char, seqan::Alloc<void> >, std::pair<seqan::String<char, seqan::Alloc<void> > const, unsigned int>, std::allocator<std::pair<seqan::String<char, seqan::Alloc<void> > const, unsigned int> >, std::_Select1st<std::pair<seqan::String<char, seqan::Alloc<void> > const, unsigned int> >, std::equal_to<seqan::String<char, seqan::Alloc<void> > >, std::hash<seqan::String<char, seqan::Alloc<void> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, false, false, true>::find(seqan::String<char, seqan::Alloc<void> > const&)': fastq_reader.cpp:(.text._ZNSt10_HashtableIN5seqan6StringIcNS0_5AllocIvEEEESt4pairIKS4_jESaIS7_ESt10_Select1stIS7_ESt8equal_toIS4_ESt4hashIS4_ENSt8__detail18_Mod_range_hashingENSF_20_Default_ranged_hashENSF_20_Prime_rehash_policyELb0ELb0ELb1EE4findERS6_[std::_Hashtable<seqan::String<char, seqan::Alloc<void> >, std::pair<seqan::String<char, seqan::Alloc<void> > const, unsigned int>, std::allocator<std::pair<seqan::String<char, seqan::Alloc<void> > const, unsigned int> >, std::_Select1st<std::pair<seqan::String<char, seqan::Alloc<void> > const, unsigned int> >, std::equal_to<seqan::String<char, seqan::Alloc<void> > >, std::hash<seqan::String<char, seqan::Alloc<void> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, false, false, true>::find(seqan::String<char, seqan::Alloc<void> > const&)]+0x8a): undefined reference to `std::hash<seqan::String<char, seqan::Alloc<void> > >::operator()(seqan::String<char, seqan::Alloc<void> >) const'
collect2: ld gab 1 als Ende-Status zurück