Hi Oliver, does one of these solutions work? http://en.wikipedia.org/wiki/Unordered_associative_containers_(C%2B%2B)#Custom_hash_functions *m ________________________________________ From: Oliver Stolpe [oliver.stolpe@fu-berlin.de] Sent: Thursday, September 13, 2012 11:21 AM To: seqan-dev@lists.fu-berlin.de Subject: [Seqan-dev] CharString as a key in an unordered_map 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_reader CMakeFiles/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 _______________________________________________ seqan-dev mailing list seqan-dev@lists.fu-berlin.de https://lists.fu-berlin.de/listinfo/seqan-dev