VC Express 2008 でLoki::Singleton、Loki::SmartPtr、およびstd::vectorを使用しているときに問題が発生しました 。以下は私のソースです。
#include <iostream>
#include <vector>
#include <loki/Singleton.h>
#include <loki/SmartPtr.h>
class Foo {
public:
std::vector<Loki::SmartPtr<Foo>> children ;
void add() {
Loki::SmartPtr<Foo> f = new Foo ;
children.push_back(f) ;
}
Foo () {
}
~Foo () {
}
} ;
typedef Loki::SingletonHolder<Foo> SingletonFoo ;
int main ()
{
std::cout << "Start" << std::endl ;
SingletonFoo::Instance().add() ;
std::cout << "End" << std::endl ;
}
コンパイルとリンクは問題ありませんが、プログラムの終了後にエラーが表示されます。
Windows has triggered a breakpoint in test.exe.
This may be due to a corruption of the heap, which indicates a bug in test.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while test.exe has focus.
The output window may have more diagnostic information.
一部のメモリが2回削除されているようですが、よくわかりません。それは VC のバグですか、それとも使用済みの Loki が恋しいですか?
前もって感謝します。