NULL ise: Eğer doğrutesti Shared_ptr aşağıdaki kod parçacığını sahip
std::vector< boost::shared_ptr<Foo> >::iterator it;
it = returnsAnIterator();
// often, it will point to a shared_ptr that is NULL, and I want to test for that
if(*it)
{
// do stuff
}
else // do other stuff
test muyum? boost dokümanlar bir Shared_ptr örtük bir bool dönüştürülebilir olduğunu söylemek, ancak bu kodu çalıştırdığınızda o çalışma sırasında parçalama arızası: Evet, doğru test ediyoruz
Program received signal SIGSEGV, Segmentation fault.
0x0806c252 in boost::shared_ptr<Foo>::operator Foo*
boost::shared_ptr<Foo>::* (this=0x0)
at /usr/local/bin/boost_1_43_0/boost/smart_ptr/detail/operator_bool.hpp:47
47 return px == 0? 0: &this_type::px;
Yineleyici 'vector.begin()' dir, görünüşe göre yanlış şeyi test ediyordum. Yardım ettiğin için teşekkür ederim. – Max