LoginSignup
3
3

More than 5 years have passed since last update.

cocos2d-x v3で、VectorのConstructorのstatic_assertにかかった時に確認すること

Last updated at Posted at 2015-02-10

今日2回も引っかかったのでメモ。

問題

コンパイル時にCCVector.hのstatic_assertに引っかかった。

CCVector.h
static_assert(std::is_convertible<T, Ref*>::value, "Invalid Type for cocos2d::Vector<T>!");

grep Vectorしてみたが、とあるヘッダファイルの

piyo.h
cocos2d::Vector<MySprite*> mySprites; // MySpriteはcocos2d::Spriteを継承 

しか引っかからない。
はて、なんだろう。

答え

piyo.hclass MySpriteを前方宣言していたのでした。

piyo.hではclass MySpriteの使用はポインタだけだったのでC++的にはOKだけど、
cocos2d::Vector的にはRefのポインタかどうか分かんねーよ、って事だったのね。
納得。

余談

今回は単純に#include "MySprite.h"で済んだけど、相互参照してたらどうするんだべ。
実装パターンを変えるしかないのかな。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3