std::vectorは確かに素晴らしいですね。
ただし、要素を追加するためEXC_BAD_ACCESS
に使用しています。push_back
(私はかつて同様の問題を抱えていましたが、SOで調べて解決しました!悲しいことに、これは別の問題のようです。)
class BackgroundGroupsHandler {
public:
void addBeat(Beat *b);
vector<beat_display_group*> groups;
};
(Beat
いくつかのデータを運ぶ単純な構造体のようなクラスです。)
class beat_display_group {
public:
void draw_me(float, float, float, int);
beat_display_group(int rhythmInt, int beatNumber);
~beat_display_group();
int posy;
private:
int rhythmInt;
int beatNumber;
int posx;
};
(beat_display_group
いくつかの数字を処理して、各グループを画面上の適切な場所に配置します。)
class BackgroundGroupsHandler {
public:
void addBeat(Beat *b);
vector<beat_display_group*> groups;
};
そして、ここに問題があります:
void BackgroundGroupsHandler::addBeat(Beat *b) {
beat_display_group *c = new beat_display_group(b->rhythmInt);
// EXC_BAD_ACCCESS ON THIS LINE:
groups.push_back(c);
}
時々gdb
私を連れて行きますstl_vector.h
:
// [23.2.4.2] capacity
/** Returns the number of elements in the %vector. */
size_type
size() const
{ return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
その他の時間new_allocator.h
:
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 402. wrong new expression in [some_] allocator::construct
void
construct(pointer __p, const _Tp& __val)
{ ::new(__p) _Tp(__val); }
void
destroy(pointer __p) { __p->~_Tp(); }