weak_ptr
GCC4.7.2を使用して2セットのC++11を比較しようとしています。以下のコードは、エラーを再現する可能な最小のサンプルを示しています。
std::set<std::weak_ptr<int>, std::owner_less<std::weak_ptr<int> > > set1;
std::set<std::weak_ptr<int>, std::owner_less<std::weak_ptr<int> > > set2;
bool result = (set1 == set2);
上記をコンパイルしようとすると、エラーの長いリストが生成されます。そのうちの最初の実際のエラーは次のとおりです。
/usr/include/c++/4.7/bits/stl_algobase.h:791:6: error: no match for ‘operator==’ in ‘__first1.std::_Rb_tree_const_iterator<_Tp>::operator*<std::weak_ptr<int> >() == __first2.std::_Rb_tree_const_iterator<_Tp>::operator*<std::weak_ptr<int> >()’
の一時的な性質のために、weak_ptr
それらのセット全体を比較することは不可能ですか?
アップデート:
1つの提案は使用することです:
bool result = !((set1 < set2) || (set2 < set1))
これにより、次のようになります。
/usr/include/c++/4.7/bits/stl_algobase.h:882:6: error: no match for ‘operator<’ in ‘__first1.std::_Rb_tree_const_iterator<_Tp>::operator*<std::weak_ptr<int> >() < __first2.std::_Rb_tree_const_iterator<_Tp>::operator*<std::weak_ptr<int> >()’