アプリケーションのブーストと標準の unordered_set を使用しようとしています。目的は、場所、つまりこのセット内の特定の要素のインデックスを見つけることです。結果には微妙な違いがあります。この簡単なプログラムに従って、boost の要素が反転されます。問題はどこだ?
シンプルな「what-if」コード:
#include <iostream>
#include <iterator>
#include <unordered_set>
#include <boost/unordered_set.hpp>
//using boost::unordered_set;
using std::unordered_set;
using std::distance;
int main()
{
unordered_set<int> Set;
int sz = 10;
for(int k=0;k<sz;k++)
Set.insert(k);
unordered_set<int>::iterator ind_searched = Set.find(8);
unordered_set<int>::size_type indx = distance( Set.begin(),
ind_searched );
std::cout << " Index of element is "
<< indx << std::endl;
return 0;
}
ブーストで私は得る
Index of element is 1
そして、標準の unordered_set を使用すると、取得しています
Index of element is 8
私は両方をコンパイルします
g++ sgi_stl_1.cc -I /home/utab/external_libraries/boost_1_48_0/ -std=c++0x