🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Problem registering vectorbool

Started by
1 comment, last by mckracken 17 years, 1 month ago
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!!!
=====================================Regards,Juan Pablo (McKrackeN) Bettini Psychoban Official Site:http://www.psychoban.comPsychoban on iTunes App Store:http://itunes.apple.com/us/app/psychoban/id378692853?mt=8
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.
Ok! Thanks very much!!
=====================================Regards,Juan Pablo (McKrackeN) Bettini Psychoban Official Site:http://www.psychoban.comPsychoban on iTunes App Store:http://itunes.apple.com/us/app/psychoban/id378692853?mt=8

This topic is closed to new replies.

Advertisement