Jump to content
  • Advertisement
Sign in to follow this  
mckracken

Problem registering vectorbool

This topic is 4079 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!