and thanks for any input. I have a large dataset I am trying to manipulate. I am holding active elements in a list, and removing them when they become inactive. I want to hold all elements active and inactive in some data structure. Currently trying a map or an unordered_map, but am welcome to any suggestions.
I am compiling with
clang++ -std=c++11 -Wall -Wextra
When trying map:
#include <map>
std::map <class1, std::string> fullMap;
//and later...
for (std::list<class1>::iterator x = l.begin(); x != l.end(); x++)
{
fullMap[(*x)] = s
}
output reads:
error: invalid operands to binary expression ('const class1' and 'const class1') { return __x < __y; }
Even though I have overloaded the less than operator for class1. This error originates at the overloaded bracket operators for map. To circumvent I tried storing in an unordered_map.
#include <unordered_map>
std::unordered_map <class1, std::string> fullMap;
and the program fails at the initialization of fullMap with the even more confusing:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/include/g++-v4/bits/hashtable_policy.h:830:23: error: implicit instantiation of undefined template 'std::hash' bool __use_ebo = !__is_final(_Tp) && __is_empty(_Tp)> ^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/include/g++-v4/bits/hashtable_policy.h:1073:15: note: in instantiation of default argument for '_Hashtable_ebo_helper<1, std::hash >' required here private _Hashtable_ebo_helper<1, _H1>, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/include/g++-v4/bits/hashtable_policy.h:1403:12: note: in instantiation of template class 'std::__detail::_Hash_code_base >, std::__detail::_Select1st, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>' requested here : public _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash, ^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/include/g++-v4/bits/hashtable.h:175:14: note: in instantiation of template class 'std::__detail::_Hashtable_base >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits >' requested here : public __detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, ^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/include/g++-v4/bits/unordered_map.h:100:18: note: in instantiation of template class 'std::_Hashtable >, std::allocator > >, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits >' requested here _Hashtable _M_h; ^
main.cpp:34:44: note: in instantiation of template class 'std::unordered_map, std::hash, std::equal_to, std::allocator > > >' requested here std::unordered_map fullMap; ^
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/include/g++-v4/bits/functional_hash.h:58:12: note: template is declared here struct hash;
I tried to cut the code down only to the relevant chunks, but let me know if more information is needed. Thanks for reading, any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire