gcc の STL を STLPort 5.0 に入れ替え
インストール自体は簡単。適当な場所にアーカイブを展開して、
sudo make -f gcc.mak clean install
できたら試しに次のコードをコンパイルしてみる。
#ifdef _DEBUG
#define _STLP_DEBUG 1
#else
#undef _STLP_DEBUG
#endif
#include <vector>
int main(void)
{
std::vector<int> hoge;
hoge.pop_back();
return 0;
}Release
g++ -pthread -L/usr/local/STLport-5.0/lib -I/usr/local/STLport-5.0/stlport/ -lstlport -O2
Debug
g++ -pthread -L/usr/local/STLport-5.0/lib -I/usr/local/STLport-5.0/stlport/ -lstlportstlg -D_DEBUG -ggdb -O
Release 版は実行すると無言で落ちる。が、Debug 版は STL の使いかたがまずいところを教えてくれる。STLPort の Debug mode は最高ですよ。
% ./a.out
/usr/local/STLport-5.0/stlport/stl/debug/_vector.h(326): STL error : Trying to extract an object out from empty container
/usr/local/STLport-5.0/stlport/stl/debug/_vector.h(326): STL assertion failure: !this->empty()
zsh: 12094 abort ./a.out