We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
Templated containers
Templated containers
Bug #2790 [Closed]
I have an implementation of Vector<>
here:
https://github.com/ricardoquesada/cocos2d-x/blob/template\_vector/cocos2dx/cocoa/CCVector.h
they should not inherit from Object.
If the new containers don’t inherit from Object, we will not be able to pull a Vector to another Vector or value of Map.
In this way, the compatibility will be broken since cocos2d::Array
and cocos2d::Dictionary
are inherited from Object which reference counted.
They could be used in a nested.
cocos2d-x has
Dictionary
,Array
,Set
an other containers. They are handy but they are not very C*+ friendly.C*+ is an static language by design, and being static has many benefits (performance for example, compiler warnings, etc).
For that reason we need templated containers, like the
std
ones.For example:
cocos2d::Vector<T>
cocos2d::Map<T>
Ideally, we should define
Array
andDictionary
as:… but I think it won’t be possible since
cocos2d::Map
andcocos2d::Vector
should be able to be created on the stack: nocreate
functions for these objects… also, they should not inherit fromObject
.The different between
std::map<>
andcocos2d::Map<>
is thatcocos2d::Map<>
MUST work with ref counted objects. It will doretain
/release
for all the objects.