S.F.Tracker(148)

公開:2006-02-16 05:31
更新:2020-02-15 04:36
カテゴリ:sftracker,c++,windows,audio,tracker

template関数のfriendでハマっている。
template class 内でtemplate 関数をfriendしたいのだが、できない。
test_machine_baseはmachine_creatorクラスでconstruct→init()するようにしている。
test_machine_baseはpost constructor(init()関数)を持ち、constructorだけでは初期化できないためである。
なので、test_machine_baseはmachine_creatorを通じてしかobjectの生成を許さないようにするため、constructorをprivateにし、machine_cretorをfriendにしている。
しかし、そうすることでboost::serialization::load_consttuct_data()中のplacement newが呼び出せなくなるので、load_consttuct_data()もfriendにする必要がある。
これができない。

これをコンパイルするとコンパイルエラーが発生する。

test_machine.cpp
c:\My Documents\Visual Studio Projects\SFTracker\test_machine.h(48) : error C2888: 'void boost::serialization::load_construct_data(Archive &,sf::model::machine::test_machine_base *,const unsigned int)' : シンボルは名前空間 'machine' 内で定義できません。
c:\My Documents\Visual Studio Projects\SFTracker\test_machine.h(216) :
コンパイルされたクラスのテンプレートのインスタンス化 'sf::model::machine::test_machine_base' の参照を確認してください
定義しているわけではないのだが....。
少しハマッたのち、別の案を検討することにする。