Boost logo

Boost Users :

From: Miles Bader (miles.bader_at_[hidden])
Date: 2007-09-19 22:52:47


I tried changing some of my code that used std::vector<foo *> to using
boost::ptr_vector<foo> (to get automatic deallocation and the slightly
nicer syntax), but the resulting compiled code seems oddly bloated
compared to the original code using std::vector. My intuition is that
the two should generally compile to largely equivalent object code,
except where there's a necessary functional difference.

Some of the problem seems to be that it does null-pointer checking at
_access_ time, instead of when adding new entries. The result is that
(for instance) calls to operator[] end up with an "unnecessary" null
check, which drags in tons of stuff related to the accompanying
assertion failure, some of which is apparently unshared across object
files, like the long __PRETTY_FUNCTION__ strings passed to the assertion
failure call.

What's the general impression people have of boost::ptr_vector and
related classes? Do people use it? Does it have a "bloat" reputation?

Thanks,

-Miles

-- 
"Suppose we've chosen the wrong god. Every time we go to church we're
just making him madder and madder." -- Homer Simpson

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net