map and unordered_map are not available because they take 2 template parameters
Means you can't make a template specialization of the entire container. Making a tempspec of the container is supposed to give you slightly more speed because it won't have to worry about the contained types in runtime. You can still use your c++ class with the actual angelscript template type container by registering that hash functor template specialization for your c++ vector class. Looks all the same in script in the end, just 1% slower.
edit: just found out that you need something more.
Got a space hash unordered_map working with my own c++ vec3 as the key, but it needs more than just the hash functor tempspec.
Because unordered_map is always an actual angelscript template object, it treats your c++ vector type as a script object.
So you also need to tell your angelscript engine that your c++ vector class has a hashing function with RegisterObjectMethod.
I got it working with code like this:
edit3: these fucking code boxes keep on exploding
//you need to include aatc_common.hpp instead of just aatc.hpp for the hashing templates
#include "aatc_common.hpp"
template<> class aatc_functor_hash<myVec3>{
public:
aatc_hash_type operator()(const myVec3& a) const{
return (a.x * 73856093) ^ (a.y * 19349663) ^ (a.z * 83492791);
}
};
void Register_All_My_Things(engine){
...
...
engine->RegisterObjectType("myVec3", sizeof(myVec3), asOBJ_VALUE ...);
...
engine->RegisterObjectMethod("myVec3", "bool opEquals(const myVec3 &in) const", ...);
...
//this line is new stuff
//engine->RegisterObjectMethod("myVec3", "uint64 hash()", asFUNCTION(aatc_func_hash_value<myVec3>), asCALL_CDECL_OBJLAST);
//edit2: use this instead, for automated hash result typenames
aatc_Register_aatc_func_hash_value<myVec3>(engine, "myVec3");
...
...
aatc_RegisterAllContainers(engine);
}
I just now implemented "aatc_func_hash_value" which is a templated function to wrap a templated functor (...) for this purpose, because angelscript don't want to register no functors. You'll have to grab a new version from the old link, only "aatc_common.hpp" has changed.
edit2: more changes!
aatc_config.hpp now has settings for hash return type bitness. Previously it assumed std::size_t and unsigned int 64 to be the same, which might have caused explosions in 32 bit projects. The settings are set automatically, but you can change them manually if you like.
aatc_Register_aatc_func_hash_value<myVec3>(engine, "myVec3"); implemented. It will take care of using the correct types when registering hash functions for your c++ classes.
"it.current_value()" and friends can now have their names configured in aatc_config.hpp
line = #define aatc_name_script_iterator_method_current_value "current_value"