Sign in to follow this  

Problem registering vectorbool

This topic is 3864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! I have a problem of "type-cast" when I try to register vector<bool>. Here's the code that where the problem is: if (ScriptMgr::RegisterObjectBehaviour("bool[]", asBEHAVE_INDEX, "bool &f(int)", asMETHODPR(vector<bool>, operator[], (vector<bool>::size_type), bool &), asCALL_THISCALL) < 0) return false; I've registered several kind of vectors without problems, but in that line the compiler show the error: c:\!\src\engine\scriptmgr.cpp(228) : error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'bool (__thiscall std::vector<_Ty,_Ax>::* )(__w64 unsigned int)' 1> with 1> [ 1> _Ty=bool, 1> _Ax=std::allocator<bool> 1> ] 1> None of the functions with this name in scope match the target type I don't know whats happening. Thanks!!!

Share this post


Link to post
Share on other sites
Vector<bool>::operator[] does not return a bool&, because vector<bool> is not, actually, a vector. It stores the booleans packed such that a single bool takes only a single bit, so operator[] has to return a proxy type. It was meant as an example of how to write a proxied container, but it is really just proof that you can't write a proxied vector and stay within the standard's requirements for vectors.

Bind a vector<int> or vector<char> instead.

Share this post


Link to post
Share on other sites

This topic is 3864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this